-1
我有一个程序,提示用户输入一个不是负数或字符的整数。我想提示用户输入一个浮点数。我该怎么做呢?如何在c中输入float时进行错误检查?
do {
printf("Enter a number.\n");
} while(((scanf("%d%c", &x1, &term) != 2 || term != '\n')
&& reset_stdin()) || x1 < 1);
int reset_stdin()
{
while (getchar()!='\n');
return 1;
}
何必下投票? – user5410809