请问对于这个函数,如果输入字母a,调试的时候不断执行if语句,不断的输出printf内容,这个达不到如果输入错了再可以重新输入的效果,求解.
本帖最后由 snake406635029 于 2013-06-04 09:11:00 编辑
void A()C scanf
{
int temp_c = 0 ;
printf("等待输入...\n");
scanf("%d",&temp_c);
if(temp_c < 1 || temp_c > 4)
{
printf("您输入的有误,请重新输入:\n");
A();
}
}
void A()
{
int temp_c = 0 ;
printf("等待输入...\n");
scanf("%d",&temp_c);
if(temp_c < 1
[解决办法]
temp_c > 4)
{
printf("您输入的有误,请重新输入:\n");
fflush(stdin);//刷新输入缓存。
A();
}
}