[Error] expected identifier before 'false'

有时编写如下程序

#include <stdio.h>
#include <string.h>

#define MAXN 20
typedef enum {false, true} bool;

bool palindrome( char *s );

int main()

{

XXXXXXXXXXXXX

}

会遇到以下问题:

注意:

错误应该发生在typedef enum {false, true} bool

.cpp与.c在语法上有些不同,而且bool在c++中是种类型,不能再被定义

解决方法:

更改文件项目,将.cpp改为.c

猜你喜欢

转载自blog.csdn.net/weixin_44227356/article/details/86629205