View Single Post
Old 07-10-2002, 03:57 AM   #6 (permalink)
redhead
Newbie
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,712
redhead is on a distinguished road
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?
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote