I wrote a program that uses an unsigned long long as storage for the user input. Even though my program tells the user NOT to input negative numbers, I am extremely sure that it would be the first thing he/she will try. Also, I can't accept floating point numbers (duh). So, I need to show an error message somehow if the user inputs a negative number, instead of using the undefined number that will appear. My question is, how can I check for negative input or floating point input if I want to store the whole value to an unsigned long long? I read the user input like this:
And after that, well, I can't check if the number is negative or floating point because what the variable contains is a positive piece of junk. I thought I could also use atoi() or atof(), but that is only for integers or floats and I need full unsigned long long!Code:scanf("%I64u",&var);
Thanks