Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int getValue(const string & prompt)
- {
- int val;
- if (cout << prompt, !(cin >> val))
- {
- cin.clear();
- dumpLine();
- return -1;
- }
- return val;
- }
- int main(void)
- {
- //whatever else menu code or w/e you have here
- int userReply = 0;
- do{
- userReply = getValue("Choose something between 1 and 4: ");
- }while(userReply <= 0 || userReply >= 5);
- // and once the user picks a good choice between 1 and 4, do other shit
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement