I have been looking around the internet all day looking for a way to stop my program from entering an infinite loop when the user enters anything except a number when I cin an int.
For example:
while(blah blah)
{
int x;
cin >> x;
if(x == 4)
break;
}
If the user enters anything but a number, the loop will never exit and it will never ask the user to input another number. I've tried using static_cast but that doesn't work either. I am at a complete loss as to what to do. I am using Visual Studio 2010 if that matters.