int main(void)
{
char ch;
printf("give me a letter in the alphabet ,and i will give ");
printf("an animal name \n beginning with that letter.\n");
printf("please type a letter ; type # to end my act.\n");
while((ch = getchar()) != '#')
{
if ('\n' == ch)
continue ;
if (islower(ch)) // 只接受小写字母
switch(ch)
{
case 'a' :
printf("A\n");
break;
case 'b' :
printf("B\n");
break;
case 'c' :
printf("C\n");
break;
case 'd' :
printf("D\n");
break;
case 'e' :
printf("E\n");
break;
default://补集;
printf("sb!\n");
}
else
printf("i regonize only lowercase letters .\n");
while(getchar() != '\n')
continue;
printf("please type another letter or a #.\n");
}
printf("done!");
return 0;
}
想问一下这条代码
while(getchar() != '\n')
continue;
printf("please type another letter or a #.\n");
的部分,如果我将36行和37行换一下位置,那么程序就不会有printf的打印,为什么?