I am using the switch case below and this section is not allowing the user to be able to re-input the value they want to enter and repeatedly shows the same code in the program.
case 5: iMenu = 5;
{
cout << "Are you sure you would like to exit? Type 1 or 2." << endl << endl;
cout << "1. Yes" << endl;
cout << "2. No" << endl;
int iExit;
cin >> iExit;
if (iExit == 1)
{
return 0;
}
if (iExit == 2)
{
goto CalculatorMenu;
}
else
{
cout << "Incorrect choice was entered, please input 1 or 2." << endl << endl;
cin >> iExit;
}
}
It repeats the cout at the beginning of the case endlessly. Any help with this will be greatly appreciated and I can show more code of the entire program if required. Thanks a lot.
Aucun commentaire:
Enregistrer un commentaire