#include <stdio.h>
int main()
{
float firstNum;
while (scanf("%f", &firstNum) == 0) {
printf("Enter a NUMBER: ");
}
return 0;
}
В чем проблема?
scanf("%*[^\n]");
:while (scanf("%f", &firstNum) == 0) {
printf("Enter a NUMBER: ");
scanf("%*[^\n]");
}
#include <stdio.h>
int main()
{
int scanf_res = 0;
double firstNum;
do
{
printf("Enter a NUMBER: ");
fflush(stdin);
scanf_res = scanf("%lf", & firstNum);
}
while (scanf_res == 0);
printf("NUMBER = %f", firstNum);
return 0;
}