关于printf和之后错误
#include<stdio.h>#include <stdlib.h>
printf("请输入月份:");
int month;
scanf("%d",&month);
switch ( month ){
case 1: printf("January\n"); break;
case 2: printf("February\n"); break;
case 3: printf("March\n"); break;
case 4: printf("April\n"); break;
case 5: printf("May\n"); break:
case 6: printf("June\n"); break;
case 7: printf("July\n"); break;
case 8: printf("August\n"); break;
case 9: printf("September\n"); break;
case 10: printf("October\n"); break;
case 11; printf("November\n"); break;
case 12; printf("December\n"); break;
}
4 8 D:\hello.c expected declaration specifiers or '...' before string constant
6 7 D:\hello.c expected declaration specifiers or '...' before string constant
6 12 D:\hello.c expected declaration specifiers or '...' before '&' token
7 1 D:\hello.c expected identifier or '(' before 'switch'
这四个错误是怎么回事,为什么错误呀。 #include<stdio.h>
#include <stdlib.h>
//首先,代码要放到一个函数里头
//而且,需要一个 main 函数
//另外,错误请看代码中的注释。
int main()
{
printf("请输入月份:");
int month;
scanf("%d",&month);
switch ( month )
{
case 1: printf("January\n"); break;
case 2: printf("February\n"); break;
case 3: printf("March\n"); break;
case 4: printf("April\n"); break;
case 5: printf("May\n"); break; //;打成了:
case 6: printf("June\n"); break;
case 7: printf("July\n"); break;
case 8: printf("August\n"); break;
case 9: printf("September\n"); break;
case 10: printf("October\n"); break;
case 11: printf("November\n"); break;//:打成了;
case 12: printf("December\n"); break;//:打成了;
}
return 0;
}
xieglt 发表于 2020-10-28 16:15
感谢
页:
[1]