How to give the user multiple options to select from

I youtubed a c++ game video and this guy made an incredible c++ game w/out using any api libs or anything and the most craziest thing I seen this guy do in his game was giving the user the option of selecting more than one option in a single command. For example:

After a code snippet finishes, he asks the user do they want to [r]eturn to the main menu, [f]ight again, or [q]uit the game. The user would either type r, f, or q.

How does a programmer do this?
1
2
3
4
5
6
7
8
9
char input;
cout << "do you want to [r]eturn to the main menu, [f]ight again, or [q]uit the game?" << endl;
cin >> input;
if (input == 'r')
{ // code to return to main menu }
else if (input == 'f')
{ // code to fight again }
else if (input == 'q')
{ // code to quit } 
Hey thanks Moschops. Is there any way to make the code loop back to any specified part of the original code w/out typing new code with if/else's?
C++ presents three loop constructs; while, do-while, and for.
Topic archived. No new replies allowed.