-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