[英]How do I fix expected identifier error in c?
我试图提示用户输入 1-8 之间的数字,如果他们没有正确响应,则重新提示。 但是,当我尝试编译我的代码时,我得到了这些错误。
mario.c:4:15: error: expected ';' after top level declarator
int main(void)
^
;
mario.c:6:1: error: expected identifier or '('
{
^
2 errors generated.
这是我的代码:
#include <stdio.h>
int main (void)
int height;
{
do
{
height = get_int ("Enter Height: ");
}
while (height > 8 || <1);
}
左括号应该直接在main
之后,而不是在声明height
之后。
另外while(height >8 || <1)
应该是while(height >8 || height <1)
。
int main(void){
int height;
do
{
height = get_int("Enter Height: ");
}
while(height >8 || height<1);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.