枚举enum不能编译通过,求助。
#include <stdio.h>int main(void)
{
enum weekday {sun,mon,tue,wed,thu,fri,sat} day;
int k;
printf("input a number(0--6)");
scanf("%d",&k);
day=(enum weekday)k;
switch(day)
{
case sun:printf("sunday/n");break;
case mon:printf("monday/n");break;
case tue:printf("tuesday/n");break;
case wed:printf("wednesday/n");break;
case thu:printf("thursday/n");break;
case fri:printf("friday/n");break;
case sat:printf("satday/n");break;
default:printf("input error/n");
} /*提示这行不能编译通过。。 问题出在哪里??新手救助*/
system("pause");
}
/n是什么???
是不是\n
啊!~~~~~~~~~~~ 拷贝我的即可
#include <stdio.h>
int main(void)
{
enum weekday {sun,mon,tue,wed,thu,fri,sat} day;
int k;
printf("input a number(0--6)");
scanf("%d",&k);
day=(enum weekday)k;
switch(day)
{
case sun:printf("sunday/n");break;
case mon:printf("monday/n");break;
case tue:printf("tuesday/n");break;
case wed:printf("wednesday/n");break;
case thu:printf("thursday/n");break;
case fri:printf("friday/n");break;
case sat:printf("satday/n");break;
default:printf("input error/n");
}
system("pause");
}
页:
[1]