substitute for goto

I was wondering if there is a substitute for a goto statement at the
1
2
3
4
5
6
7
if(players_input=="inventory"){
       void inventory(); 
       //need something for here
    }
    else if(players_input=="stats"){
        int playerStats();
        //need something for here 


as after it has been to inventory or playerStats I would like it to return to the top of "string input" function.
I can use goto but I have heard that it is a bad practice so if there is another way I will use that instead.
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
31
32
33
34
35
36
 //gets players input then goes to inventory/stats/quits or returns move to story
string input(bool Forward, bool Left, bool Right, bool Backwards){
    //goto here
    if(Forward)
        string Forward2="forward";
    if(Left)
        string Left2="left";
    if(Right)
        string Right2="right";
    if(Backwards)
        string Backwards2="backwards";
    //preferably here.
    cout<<"Enter the corresponding word to do the following: \n";
    cout<<"If you would like to move please enter:\t 'move'\n";
    cout<<"If you would like to see your inventory please enter:\t 'inventory'\n";
    cout<<"If you would like to see your statistics please enter:\t 'stats'\n";
    cout<<"If you would like to quit then please enter:\t 'quit'\n\n";
    cout<<"Input: ";
    cin>>string players_input;
    while(players_input!="inventory" || players_input!="stats" || players_input!="quit" || players_input!="move"){
            cout<<"You have entered a invalid command. Please re-enter: "
            cin>>players_input;
            }
    if(players_input=="inventory"){
       void inventory(); 
       //need something for here
    }
    else if(players_input=="stats"){
        int playerStats();
        //need something for here
    }
    else if(players_input=="quit"){
        return ("quit")
    }

}


(i haven't compiled it yet so there may be a few mistakes and it is not finished yet.) Thank you for any advice.
1
2
3
4
5
6
7
8
9
string input(...)
{
    std::string player_input;
    while (player_input != quit)
    {
        //...
    }
    return player_input;
}
Thank you kbw
Topic archived. No new replies allowed.