I have a program that defines an int data variable
The program uses scanf("%d",&data) to read data from stdin. If the data from stdin is not integers, I should print an error message.
I tried if(scanf("%d",&data) ==EOF){ printf("error");return 1;}
He did not work for me. So, how can I tell if scanf crashes or fails?
Yakov source share