一个关于switch的小程序,实在看不出什么毛病啊??为什么总是不对呢
/*今天下午编了几个小程序,但其中有个程序却总是出错,
*我试了很久还是找不出问题所在,百思不得其解啊!
*把程序精简了一下,只保留了有问题的部分,贴在此处,请大家不吝赐教!
*(我用的是visual c++ 6.0,建立的Win32 Console Application。 )
*
*/
#include "stdio.h"
main()
{
char t;
t=getchar();
switch(t)
{
case 'S':
printf("Please enter the second letter:\n");
if (getchar()=='u')
{
printf("Sunday\n");
}
default:
printf("Wrong input!\n");
}
}
每次运行后,输入S,按enter之后,就会出现:
Please enter the second letter:
Wrong input!
Press any key to continue
这样程序就算结束了,根本不给我输入第二个字符的机会。
这究竟是为什么?
小女子在此谢过了先~~~