// char a = getch();
// bool found = false;
// while (a < '1' || a > '6') //only accepts 1-5 input from keyboard for switch
// {
// a = getch();
// }
// cout << "You chose " << a << endl;
Leppie. (Maybe I shouldn't post yet)!
Hope it helps!
The simple way works for homework and the like. It will accept inputs of the form "123x" though, reading the integer '123' and leaving the 'x' behind. This may or may not be useful, depending on whether or not your input should have spaces between things.
The less simple way is to make sure the input does not validate when something like "123x" is entered. However, the way it is done in the link I gave you requires the user to have only one thing on a line. (That is, the answer has to be "123" + ENTER.) The simpler way would allow you to have more than one thing on a line...
Perhaps I'll write up an article with both these ways plus an advanced, no ENTER necessary input validation method... (so that the >> operators can be used instead of requiring the user to input only one item per line).