Well. I'm having a little bit of an issue, and I'm taking it's just from my absolute lack of experience with C++ atm. But hey, lets give this a go. So, I'm constructing a little menu system. So, I'm using the Do..While statement, while in one itself. (Mind you, I'm still on the first few lessons, but I'm still fiddling around with them. So I'll gladly take some advice on better methods, though I'm not sure if I'll understand it at this time.) So here's my code so far.
Code:
#include <iostream>
using namespace std;
int main()
{
int input;
int menu1;
int menu2;
int menu3;
int menu4;
int menu5;
menu1 = 0;
menu2 = 0;
menu3 = 0;
menu4 = 0;
menu5 = 0;
do
{
cout<<"Choose an Option.\n";
cout<<"1. Option 1.\n";
cout<<"2. Option 2.\n";
cout<<"3. Option 3.\n";
cout<<"4. Option 4.\n";
cout<<"5. Option 5.\n";
cout<<"0. Exit.\n";
cout<<"Selection: ";
cin>>input;
}while (input != 0);
switch ( input ) {
case 1:
do
{
cout<<"1. Sub1 Option 1.\n";
cout<<"2. Sub1 Option 2.\n";
cout<<"3. Sub1 Option 3.";
cout<<"4. Sub1 Option 4.";
cout<<"5. Sub1 Option 5.";
cout<<"9. Exit.";
cin>> menu1;
}while ( menu1 != 9 );
}
}
So, this code is quite incomplete. I'm still at the first stage of making it. Basically, (it's supposed to) work like this:
You choose option 1, it brings to a submenu. Then, you can choose one of the sub-submenu's. In the end, it'll be similar to a pyramid.
So a quick explanation of the variables. Input is the main input - for the first menu. Then, Menu1 controls the first submenu. So from the code I have, in essence, at the end, I could put }while ( menu != 9 && input != 0 ) and I (believe) it would still work out. It's just running both subs.
But, when I run this code, it doesn't move on from one menu to another. (Though I've only done the first sub-menu.) So when I push 1, it should move to the first case, but it doesn't. So what have I got wrong, here?