switch 输出报错!
#include <stdio.h>main()
{
char letter;
printf("please in put the first letter\n");
while (letter=getchar()!='Y')
{
switch (letter)
{
case 'M':printf("Today is Monday\n");break;
case 'T':printf("please input the second letter\n");
if (getchar()=='u')
printf("Today is Tuesday\n");
else if (getchar()=='h')
printf("Today is Thursday\n");
else
printf("data error1\n");
break;
case 'W':printf("Today is Wednesday");break;
case 'F':printf("Today is Friday");break;
case 'S':printf("please input the second letter\n");
if (getchar()=='a')
printf("Today is Satday\n");
else if (getchar()=='h')
printf("Today is Sunday\n");
else
printf("data error2\n");
break;
default:printf("data error3\n");
}
}
}
这各程序执行的时候总是输出 data error3,请帮忙查找原因,谢谢!