Can anyone please point out why I get the syntax error: expected expression before '{' tokenin
T[SIZE] = {NULL};
in the code segment below?
Thanks.
typedef struct SetObject{
int key;
struct SetObject *prev;
struct SetObject *next;
} Node;
Node *T[SIZE]; //global variable
void initT(void) {
T[SIZE] = {NULL};
}
To assign a pointer value to an array element, use:
The curly brackets around
NULLare not needed.The second problem is that
SIZEis an invalid index into theTarray. The valid indexes range from0throughSIZE-1. Assigning toT[SIZE]will lead to undefined behaviour.