Possible Duplicate:
How to initialize a struct in ANSI C
I have a global variables in my code with initial values , which are :
int init = 0;
int flag = FALSE;
sem_t *mutex;
char * ptr1 = NULL;
char * ptr2 = NULL;
int status1 = -10;
int status2 = -10;
int semaphoreFlag = FALSE;
Instead , I decided to add a struct :
struct PipeShm
{
int init;
int flag;
sem_t *mutex;
char * ptr1;
char * ptr2;
int status1;
int status2;
int semaphoreFlag;
};
However ,I can't set initial values to the struct's fields , like I did when the variables are global variables .
I guess that the usual way would be to have a void init()
method
that would set the values of the struct to the requested values ... but I'm looking for something else ... Any way around this ?
Thanks