使用带有常量变量的 if 语句时收到错误 - C

receiving error when using if statements with a constant variable - C

我的 headers 之后还有 #define MAX_PERSONS = 20;。 我正在尝试做一个 if 语句,我将 int p 与 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;
   }
}

我收到此错误 menu.c:80:10: error: expected expression before ‘=’ token。 但是,如果我像使用第二个 if 语句那样将 MAX_PERSONS 切换为 20,它就可以工作。

我想知道是否有人可以让我知道为什么会发生这种情况以及如何使用常量值。谢谢!

替换

#define MAX_PERSONS = 20;

#define MAX_PERSONS 20

#define 是一个 pr-processor 指令,它在编译前将 MAX_PERSONS 替换为后面的文本。