cin Help...Sort of a noob Question:
I have this problem with cin, and I'm not sure what to do: Here's some of my code:
My problem is thus: when you type in any other intenger besides one or two, the default message appears. But, whenever you type in a non-intenger input, the program crashes horribly. I know that since the cin variable is an intenger, that it can only accept intengers, but how do I keep the program from crashing?
cout << "\nSelect a command:";
for ( ; ; )
bool exit = false;
cout << "\n1 - Go Exploring";
cout << "\n2 - Exit";
cout << "\nCommand: ";
cin >> input;
case 1: cout << "\nOne!";
case 2: exit = true;
default: cout << "\nThat wont work."
I just want the default message to be printed once if you type in anything other than an intenger.
BTW: I know that my for ( ; ; ) could be written as while(!exit), but that's just the way I like to do my menu loops.