Reputation: 623
I have #define MAX_PERSONS = 20;
after my headers.
I'm trying to do an if statement, where I compare an int p to MAX_PERSONS
int checkString(char string[]){
int p = strlen(string);
printf("\n\t\t%s is %d characters long\n", string, p);
if (p < MAX_PERSONS){
return 1;
}
if (p > 20){
return 0;
}
}
I receive this error menu.c:80:10: error: expected expression before ‘=’ token
.
However, if I switch MAX_PERSONS to 20 like how I did with the second if statement, it works.
I was wondering if someone could let me know why this is happening and how I can use the constant value. Thanks!
Upvotes: 0
Views: 77
Reputation: 2547
Replace
#define MAX_PERSONS = 20;
with
#define MAX_PERSONS 20
#define
is a pr-processor directive which replaces MAX_PERSONS
with the followed text before compilation.
Upvotes: 4