I'm trying to validate of the user input is a positive floating point value or not.
When user input is negative, the error message kicks in correctly. But when the user input consists of letters or some other symbols aside from numbers, the error message loops perpetually.
What'm I doing wrong?
Code:
char AmtStr[99];
int i, j, Done = 0, Count = 0;
float Amt;
while (Done == 0) {
printf(" Amount you have ");
j = scanf("%f", &Amt);
if (j == 1 && Amt > 0) {
printf(" Proceed.");
break;
}
else {
printf(" Error.\n\n");
j = '\0';
Amt = '\0';
continue;
}