Skip to content

Instantly share code, notes, and snippets.

@javiermontenegro
Created November 30, 2019 21:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save javiermontenegro/4692599940c5e8aee3506f99c4e9b299 to your computer and use it in GitHub Desktop.
Save javiermontenegro/4692599940c5e8aee3506f99c4e9b299 to your computer and use it in GitHub Desktop.
This gist is a example of terminal menu in C++
/*********************************************************************
* Filename: Cpp_Terminal.Login.cpp
* Author: Javier Montenegro (javiermontenegro.github.io)
* Copyright: @2019
* Details: this gist is a example of terminal menu in C++
*********************************************************************/
#include <iostream>
#include <cstdlib>
using namespace std;
void menu();
void mainMenu();
void optionsMenu();
void options();
int choice1 = 0;
int choice2 = 3;
void menu(){
do {
choice2 = 0;
mainMenu();
switch(choice1) {
case 1:
cout << "Pew pew!\n";
break;
case 2:
options();
break;
case 3:
break;
}//End switch
} while(choice1 != 3);
}//End menu
void options(void) {
do {
optionsMenu();
switch(choice2){
case 1:
cout << "So difficult!\n";
break;
case 2:
cout << "Beep!\n";
break;
case 3:
break;
default:
break;
}//End switch
} while(choice2 != 3);
}//End options
void mainMenu(void) {
cout << "Main Menu\n";
cout << "1 - Start game\n";
cout << "2 - Options\n";
cout << "3 - Quit\n";
cout << "Please choose: ";
cin >> choice1;
}//End mainMenu
void optionsMenu(void) {
cout << "Options Menu\n";
cout << "1 - Difficulty\n";
cout << "2 - Sound";
cout << "3 - Back\n";
cout << "Please choose: ";
cin >> choice2;
}//End optionsMenu
int main(int argc, char** argv)
{
menu();
return 0;
}//End main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment