I am getting a command from the user with getline and the string is declared as pick.
When they use a certain command it takes them to another void function depending on the value they set to the string.
So I have all the main stuff like....
#include<iostream>
#include<string>
using namespace std;
void MainMenu();
void NewGame();
void LoadGame();
void GameInfo();
void Credits();
string Pick;
int main()
{
MainMenu();
}
So that is my set up...
Then this is the code I want to make sure is correct.
void MainMenu()
{
system("cls");
cout << "\nNew Game" << endl;
cout << "\nLoad Game" << endl;
cout << "\nCredits" << endl;
cout << "\nGame Info" << endl;
cout << "\nExit" << endl;
cout << "Type command: ";
getline(cin, Pick);
if(Pick = "New Game")
NewGame();
if(Pick = "Load Game")
LoadGame();
if(Pick = "Credits")
Credits();
if(Pick = "Game Info")
GameInfo();
if(Pick = "Exit")
break;
else
MainMenu();
}
I know they have to type in the string exactly to get it to call one of the functions, I am just making sure I havent missed anything in the code that would cause an error.
Thank you for any help.

New Topic/Question
Reply



MultiQuote


|