Hiya, I'm trying to make a small loop which presents an error when the user inputs something apart from a float and gives them another opportunity. Here's what I've got so far.
printf("Enter a value for x: ");
while (scanf("%lf", &x_temp) != 1) {
printf("ERROR: Input real number\n");
printf("Enter a value for x: ");
scanf("%lf", &x_temp);
}
But this just runs through the loop without giving the user another chance to enter another number:
user@user-vm:~/Desktop/Exercise_0$ ./a.out
Enter a value for x: a
ERROR: Input real number
Enter a value for x: ERROR: Input real number
Enter a value for x: ERROR: Input real number
Enter a value for x: ERROR: Input real number
Enter a value for x: ERROR: Input real number
Enter a value for x: ERROR: Input real number
Enter a value for x: ERROR: Input real number
Enter a value for x: ERROR: Input real number
Enter a value for x: ERROR: Input real number
Anyone got any ideas? Cheers guys