So here's what I've got.
Now, all the other options work, but the 'q' option will not break the while loop. Can you guys see what I'm doing wrong? I have a feeling it's something little I'm missing.Code://: C03:Menu.cpp// Simple menu program demonstrating
// the use of "break" and "continue"
#include <iostream>
using namespace std;
int main()
{
char c; // To hold response
while(true)
{
cout << "MAIN MENU:" << endl;
cout << "l: left, r: right, q: quit -> ";
cin >> c;
switch (c)
{
case 'q': break;
case 'l':
{
cout << "LEFT MENU:" << endl;
cout << "select a or b: ";
cin >> c;
switch (c);
{
case 'a':
{
cout << "You chose 'a'" << endl;
continue;
}
case 'b':
{
cout << "You chose 'b'" << endl;
continue;
}
default:
{
cout << "You didn't choose a or b!" << endl;
continue;
}
}
}
case 'r':
{
cout << "RIGHT MENU:" << endl;
cout << "select c or d: ";
cin >> c;
switch (c)
{
case 'c':
{
cout << "You chose 'c'" << endl;
continue;
}
case 'd':
{
cout << "You chose 'd'" << endl;
continue;
}
default:
{
cout << "You didn't choose c or d!" << endl;
continue;
}
}
}
cout << "you must type l or r or q!" << endl;
}
}
cout << "quitting menu..." << endl;
}