在发布这个问题之前我查了一下互联网,我发现的答案是我可能缺少括号。
int main (void) {
int input = 0;
while(input != 3) {
printf("Please select an implementation :"
"\n1. Linked list implementation"
"\n2. Ring buffer implementation"
"\n3. Exit");
fflush(stdout);
scanf("%d",&input);
switch(input) {
case 1: printf("Linked List");
break;
case 2: printf("Ring Buffer");
break;
case 3: printf("Goodbye!");
break;
}
}
return 0;
}
我删除了案例中的所有代码以使其更短,但我仍然收到错误。更具体地说:
在 int main(void) {
行我收到错误
'main' is normally a non-static function [-Wmain]
在最后一个 }
行我收到错误:
expected declaration or statement at end of input
我尝试清理和刷新,再次构建项目,我还重新启动了计算机,但没有任何变化。
非常感谢!
最佳答案
鉴于您的 .c
文件是完美的,我以前见过这个,错误一定是在您的 header (.h
) 文件之一中。
关于c - 输入末尾的预期声明或语句。我数出了正确的括号数量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27808202/