菜鸟问题
开发环境:WINDOWSXP+VC6.0
#include <stdio.h>
#include <process.h>
int main()
{
int Index = 0;
while( 1 )
{
printf( "** Please input the number:" );
//这里如果我输入的是字符,比如输入一个A,则程序在下一次循环时根本不再让我输入值(这是为什么?), 程序死循环(此时Index的值为0. scanf返回0).
//而如果输入的是数字,scanf返回1, 则下一次循环时还可以再输入值.
scanf( "%d", &Index );
if( Index < 10 )
{
printf("Nubmer is %d .", Index);
}
else
{
printf( "## The error number !!\n" );
exit( 1 );
}
}
printf("\n");
return 0;
}