- 缺少 “ ; ”【且为英文字符】
- 大结构体错误:
#include <stdio.h>
int main()
{
return 0;
}
- 报错:[Error] expected unqualified-id before ‘{’ token
【错误代码】
#include <stdio.h>
{
int main() //错误代码
int a,b,c;
return 0;
}
【正确代码】
#include <stdio.h>
int main() //正确代码 将 int main() 放置首行代码下面
{
int a,b,c;
return 0;
}
- 用户输入后 未能读取
【错误代码】
#include <stdio.h>
int main()
{
int a,b,c;
scanf("%d %d %d" ,a,b,c); // 错误代码,缺少“ & "
int max=0;
if(a>b)
{
if(a>c)
{
max=a;
}
else// a<c
{
max=c;
}
}
else// a<b
{
if(b>c)
{
max=b;
}
else// b<c
{
max=c;
}
}
printf("This is the max number:%d\n",max);
return 0;
}
【正确代码】
#include <stdio.h>
int main()
{
int a,b,c;
scanf("%d %d %d" ,&a,&b,&c); // 正确代码,添加“ & "
int max=0;
if(a>b)
{
if(a>c)
{
max=a;
}
else// a<c
{
max=c;
}
}
else// a<b
{
if(b>c)
{
max=b;
}
else// b<c
{
max=c;
}
}
printf("this is the max number:%d\n",max);
return 0;
}