This is a struct I have written.
typedef struct {
int index=NULL;
int sd;
pthread_t tid;
char* name;
}client_t;
Next I am making an array of these structs.
static client_t *clients[MAXCLIENTS];
Now in the main function, I am assigning values for these structs according to the position in the array.
clients[freeslot]->index=freeslot;
clients[freeslot]->sd=connfd;
clients[freeslot]->tid=syscall(SYS_gettid);
clients[freeslot]->name=threadnames[freeslot];
when i compile, i get these error messages.
code.c:185:12: error: ‘client_t’ has no member named ‘index’
code.c:186:19: error: ‘client_t’ has no member named ‘sd’
code.c:187:19: error: ‘client_t’ has no member named ‘tid’
code.c:188:19: error: ‘client_t’ has no member named ‘name’
I am confused about these error messages. Have I assigned values in a wrong way?
=NULLfromindex. You should also consider whether you want an array of pointers (in which case you'll need to allocate memory) or whether you meant to declare an array ofclient_tinstances -static client_t clients[MAXCLIENTS];