Goto outside function.

Hey fellas, so I'm working on a "database" console program and I've got a little problem. I decided to make every menu in the program as a serperate void function, to avoid multiple "switch" statements and so on. So I'm making a "stock" database menu and I want it to go back to the main menu, which is labeled "start:", but it's already in MAIN() function and not the stock_menu() functin.

So as a result I get "Start" is not labeled. And of course, thats because it is outside the function. So how do I make it to go back to main menu, without using goto or return?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//I am guessing a console application.
int selection = 0;
do
{
    std::wcout << L"Menu:" << std::endl;
    ... //etc. the rest of the menu here.  Asuming zero is the number to exit.
    std::wcout << L"Make your selection:  ";
    bool goodChoice;
    do
    {
        std::wcin >> selection;
        goodChoice = true;
        switch (selection)
        {
            case 1:
                FunctionForCase1();
                break;
            case 2:
                //etc.  Same thing for this and other cases.
                ...
            case 0:
                //The exit case.  Don't call any function.   Just break.
                break;
            default:
                goodChoice = false;
                std::wcout << L"Bad choice.  Try again:  ";
                break;
        }
    } while (!goodChoice);
} while (selection != 0); //can be written as:  while (selection); 


There. No nasty labels or goto's. The innermost DO loop ensures the user types a valid option while the outermost DO loop continues to present the menu until the exit option is given, which is zero in my example.
Topic archived. No new replies allowed.