gpt4 book ai didi

c - 错误 : expected identifier or ‘(’ before ‘=’ token

转载 作者:太空宇宙 更新时间:2023-11-04 05:57:15 25 4
gpt4 key购买 nike

<分区>

也许这是个简单的问题,因为我正开始在 Linux 中进行 C 编程。我正在开发客户端/服务器程序,当我尝试添加用户时,GCC 给我这个错误:“server.c:71:16: expected identifier or '(' before '=' token” 和我不明白问题出在哪里。第 71 行是我调用函数 AddUser 的时候。

int main(){

int fifo_1,fifo_2,i,num_args, status_triage, users_verify, login=0;
char name_fifo[20], comand[20], arg_1[20], arg_2[20], username[20];
struct request req;
users_list list = NULL;

//LOGIN CYCLE
do{

if(strcmp(req.str, "exit") == 0) // If the user inserts "exit"
{
printf("check1\n");
req.type = -1;
}

else // Add user
{
if(num_users < 4)
{
users_list = AddUser (list, req);
}
else if(num_users == 4) // The program has the maximum number of players
req.type=2;
}

}while(req.login == 0);

我不知道是否有必要,但我也添加了 AddUser 函数:

users_list AddUser(users_list list, req req){

users_list new, aux;

new = malloc(sizeof(users_list));

if (new == NULL){
printf("Erro na alocacao de memoria!\n");
return NULL;
}

strcpy(new->username, req.str);
new->pid = req.pid;

new->next = NULL;

if (list == NULL)
list = new;

else{
aux = list;
while (aux->next != NULL)
aux = aux->next;
aux->next = new;
}
num_users++;

return list;
}

谢谢你的时间!

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com