得到了所有的工作,感谢]C,结构内枚举,错误C2016,头文件
代码
enum genre {A, B, C, D, E};
struct recipe
{
genre category;
char name[50];
char ingredients[50];
char instruction[1000];
};
void menu();
void file_check(char *name);
错误:
error C2016: C requires that a struct or union has at least one member
error C2061: syntax error : identifier 'genre'
error C2059: syntax error : '}'
这是我的头文件。我想不通想从我这里编译:(我认为它会以这种方式工作
你认为你正在用某种C++编译器编译C语言。在C中,当引用'genre'名称时,_need_ {struct,union,enum}标记。 – wildplasser
可能的重复:http://stackoverflow.com/questions/1102542/how-to-define-an-enumerated-type-enum-in-c – Steve
我建议你看看如何typedef枚举。看到这个http://stackoverflow.com/questions/1102542/how-to-define-an-enumerated-type-enum-in-c –