How to prevent the Error of input character with scanf() ?
I simply code a similar example of problem I confusing below :
printf("\nPlease Enter Number[x]: ",x+1);
The code is work well if the scanf input is a digit.
The problem is when a character or other an undigit things is input , the code crush.
I had search this problem in Google , and I found that fflush() is work , ya ,it clear the value of scanf if get error .
But the problem is fflush() is just work on some platform , it does'nt work on Linux or even Unix system.
So , I just wonder how to fix this problem ?
Thanks For Help