{
int i=0;
while ( i != 1)
{
printf("Input a number, 1 - End, Other Number -Continue:");
scanf("%d",&i);
}
printf("Finished.\n");
return 0;
}
如果输入a你会发现一个意想不到的结果。
其中的道理如何解释。
...全文
54033打赏收藏
考考大家的C语言基础
#include #include int main() { int i=0; while ( i != 1) { printf("Input a number, 1 - End, Other Number -Continue:"); scanf("%d",&i); } printf("Finished.\n"); return 0; } 如果输入a你会发现一个意想不到的结果。 其中的道理如何解释。
{
int i=0;
while ( i != 1)
{
printf("Input a number, 1 - End, Other Number -Continue:");
scanf("%d",&i);
fflush(stdin);//清一下stdin
printf("\n%d\n",i);
}
printf("Finished.\n");
return 0;
}