There is a fix, buts thats just a small hack I came up with...
Code:
#include <iostream>
#include <limits.h>
using namespace std;
int main()
{
int i=INT_MIN;
cout << "Enter your digit: ";
cout.flush();
cin >> i;
if(i > INT_MIN)
cout << "Thanks for the integer." << endl;
else
cout << "WTF. No integer?" << endl;
return i;
}
But, then again, if the user inputs a value repressenting INT_MIN (which on 32bit architecture is
-2147483648 ) it will fail.. Yet, who would want to use that as the input value?