void main()
{
char day[20];
printf("Enter the short name of day");
scanf("%s", day);
switch(day)
{
case "sun":
printf("sunday");
break;
case "mon":
printf("monday");
break;
case "Tue":
printf("Tuesday");
break;
case "wed":
printf("wednesday");
break;
case "Thu":
printf("Thursday");
break;
case "Fri":
printf("friday");
break;
case "sat":
printf("saturday");
break;
}
}
Run Code Online (Sandbox Code Playgroud)
这是我的代码.我在开关盒part.switch的情况下得到一个错误,没有检查这些情况.请帮助我.提前致谢.
使用c,我所知道的唯一方法是:
if (strcmp(day, "sun") == 0)
{
printf("sunday");
}
else if (strcmp(day, "mon") == 0)
{
printf("monday");
}
/* more else if clauses */
else /* default: */
{
}
Run Code Online (Sandbox Code Playgroud)