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?