1 Anyone here know C++? Fri Sep 30, 2011 11:04 pm
Bla125
Registered Member
I'm making a text based game right now for my first game and need some help with a problem I have run into. It asks the player to type a number to pick a choice from the list above according to the situation presented and that all works. BUT, it shows the number that they typed in in the answer that they gave when it's not supposed to. Anyone able to help me with this?
- Spoiler:
- int main()
{
int choice;
cout << "This is the introduction \n";
cout << "other parts of the introduction \n\n";
cout << "Instructions \n";
cout << "instructions continued \n\n";
cout << "Present situation to player \n";
cout << "Present choices to player \n";
cout << "1 \n";
cout << "2 \n";
cout << "3 \n";
cout << "Players choice? ";
cin >> choice;
cout << "\nPlayers choice \n" << choice;
if (choice == 1)
{
cout << "Shows the outcome of the players choice 1 \n"; //It shows the number 1 before "shows" in this statement.
}
else if (choice == 2)
{
cout << "Shows the outcome of the players choice 2 \n";
}
else if (choice == 3)
{
cout << "Shows the outcome of the players choice 3 \n";
}
else
{
return (0);
}
getchar();
getchar();
return 0;