作者:广东没有名字的世界 | 来源:互联网 | 2023-07-12 10:02
struct Users{
int id;
char msg[];
};
int nUsers;
struct Users users[10];
void connectUser(struct Users user){
if(nUsers<10){
for(int i=0;i<10;i++){
if(users[i]==NULL){
users[i]=user;
printf("user %d connected!\n", user.id);
nUsers++;
}
}
}else
printf("number of users reached!\n");
}
That's my code and when I try to compile, comes with error:
那是我的代码,当我尝试编译时,会出现错误:
[s3450124@csitprdap01 ~]$ gcc -std=c99 socketserver.c -o socketserver
socketserver.c: In function ‘connectUser’:
socketserver.c:24: error: invalid operands to binary == (have ‘struct Users’ and ‘void *’)
socketserver.c:21: note: The ABI of passing struct with a flexible array member has changed in GCC 4.4
socketserver.c: In function ‘disconnectUser’:
socketserver.c:37: error: incompatible types when assigning to type ‘struct Users’ from type ‘void *’
Every time I try to compile, these errors comes up. Can you guys help me?
每次我尝试编译时,都会出现这些错误。你们能帮助我吗?
2 个解决方案