If he's trying to protect cin from getting slaughtered that's not going to help. If you try to cin an int and somebody puts a character string in there, cin will asplode.
Try this:
while (!cin>>IntegerVariable)
{
cout << "That's not an integer" << endl;
cin.clear();
cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
}
cout << "You entered the integer " << IntegerVariable << endl;
EDIT: If you're trying to "protect" an edit box in MFC, right click the edit box, go to the "Styles" tab and check "Number".
Users browsing this forum: No registered users and 2 guests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum