For example, I have the following code:
#define MAX_CLIENTS 100;
void main() {
char* pick[MAX_CLIENTS];
int* points[MAX_CLIENTS];
return 0;
}
Trying to compile it throws these errors:
file.c:4: error: expected ‘]’ before ‘;’ token
file.c:5: error: expected ‘]’ before ‘;’ token
If I replace MAX_CLIENTS in the subscripts with a literal 100, then the errors are gone.
Why?
the
;in#define MAX_CLIENTS 100;is redundant , remove it and you should be fine.Remember that
#defineis a pre-processor command, that replacesMAX_CLIENTSwith100;– you don’t want the semicolon there, only the 100.