The system("pause") at line 32 may have something to do with that. Happens when you press a key?
18 Replies - 2006 Views - Last Post: 04 August 2012 - 07:46 PM
#17
Re: Return to main menu after invalid choice
Posted 04 August 2012 - 06:47 PM
With the system pause, when you hit a key the invalid entry just comes up again. Without the system pause, the screen just flashes back and forth between the menu and invalid entry screen without enough time to even read what it says
#18
Re: Return to main menu after invalid choice
Posted 04 August 2012 - 07:30 PM
Try putting:
in the else clause.
cin.ignore(1000, '\n');
in the else clause.
#19
Re: Return to main menu after invalid choice
Posted 04 August 2012 - 07:46 PM
The variable selection is an int. When you attempt to enter a character the cin stream will fail. Subsequent cin calls will skip due to the stream being in a fail state.
You could use the clear function before the next read.
Another option would be to use a character type for the selection variable.
cin >> selection;
You could use the clear function before the next read.
cin.clear();
menu(selection);
Another option would be to use a character type for the selection variable.
This post has been edited by #define: 04 August 2012 - 07:46 PM
|
|

New Topic/Question
Reply




MultiQuote




|