I tried to use the return value of the scanf function in a for-loop
#include<stdio.h>
int main(){
int a, b, c;
for(a = 0; a < 10; ++a){
c = scanf("%d", &b);
if(c != 1)
printf("error ");
else
printf("ok ");
}
return 0;
}
The idea is basically to prevent the user to write anything but a int value. However it went wrong, whenever the users types a none int value, it starts to loop, printing "error" over and over again until the for-loop ends. I don't want it to 'break' the for-loop when the typed value isn't a integer, but to display the "error" message and keep receiving values until the loop ends.