I am trying to get input from the user/ file redirection and need to return an error when the input is not an integer. For this, I am using
int s= scanf("%d", x);
if (s==0){
fprintf(stderr, "Non integer value input.");
}
but this means that I can not use it to terminate the program when I run out of inputs. How can I accomplish both since getting the number of successful scans is the only way I know to figure out if the input has ended.