How to return to certain parts of the program

I have several menus and at the end i would like to set it so the user can select if he wants to go back to a certain menu or even from the beginning, i was trying to do loops with bools and it just gets really convoluted, i was wondering if there was any easier way to do this where if user said 1, he would go to the first menu, if he were to press 2 he would go to the second menu, and if he were to select 3 he would exit the program.

any help would be greatly appreciated !
something like
1
2
3
4
5
6
7
8
9
10
11
12
13
int state = 1;//enum would be nice here
while(state != 0){
    switch(state){
        case 1:
            cout << "menu 1: what do you want to do? (1 or 2. 0 to quit) ";
            cin << state;//you should deal with invalid input too.
            break;
        case 2:
            cout << "menu 2: ... ?";
            cin << something;
            break;
        //and so on...
}
Topic archived. No new replies allowed.