The idea behind my program is to get some numbers to send it asynchronously to a process. The decimals are red from the keyboard.
printf("We need integer values. Could you provide us some, please?\n");
printf("Press Ctrl-C when you have no more to give\n");
int ret = scanf("%d", &temp);
// ferror associated to stdin is 0 at this point
printf("This might not be a number.\n");
printf("Please try again. What about right now?\n");
// Good data. Can send them as useful
So, if the user sends an "it", the input shall be ignored, and user prompted for another number. At least that's what I expect. The fact is once an errouneous input is provided, the program behaves as the line containing the call to scanf didn't exist.
I tried to read ferror(stdin). It is 0 in any case.
Any hints will be endlessly appreciated.
Linux 18.104.22.168 PREEMPT i686 GNU/Linux
gcc (GCC) 3.3.6 (Debian 1:3.3.6-13)