#include <stdio.h>
main()
{
int a,b,max,ret;
printf("Input a,b:");
ret = scanf("%d,%d",&a,&b);
while (ret!=2)
{
while(getchar()!='n');
printf("Input a ,b:");
ret = scanf("%d,%d",&a,&b);
}
max =a >b? a:b;
printf("max = %d\n",max);
}
其中第二个while循环什么作用?
while(getchar()!='n');
printf("Input a ,b:");
ret = scanf("%d,%d",&a,&b);
怎么清除的缓冲区中的错误数据?
对不起打错了··第二个循环 ·while(getchar()!='\n');
是怎么回事?
对不起打错了··第二个循环 ·while(getchar()!='\n');
是怎么回事?
重新输入ab前需要敲一个'\n'(回车)确认