Text game help, how can I make player go back to previous location?

Hello, I have started making a text adventure game, I need help with some code.
if (Choice == 2)
{
cout << "" << endl << "You follow the light to the end of the hallway, you find your self in a room" << endl
<< "with natural light coming from a hole in the ceiling." << endl << "" << endl << "You hear the door you just came through, slam behind you!" << endl << "" << endl
<< "There are three possible directions." << endl << "" << endl << "Do you:" << endl << "" << endl << "1) Go forward" << endl << "" << endl << "2) Go left" << endl
<< "" << endl << "3) Go right" << endl << "" << endl << "Enter your choice: ";
scanf("%d" , &Choice );
}

if (Choice == 1)
{
cout << endl << "" << endl << "In the dim light you see a glint of white teeth, they lunge toward you and take a bite out of your neck. You die." << endl << "" << endl;
system("pause");
return 0;
}

if (Choice == 2)
{
cout << endl << "" << endl << "As you walk down a dimly lit hallway, you catch a bit of light reflecting off" << endl << "" << endl << "some metal. It's a chest!" << endl << ""
<< endl << "Do you:" << endl << "" << endl << "1) Go back" << endl << "" << endl << "2) Open the chest" << endl << "" << endl <<
"Enter your choice: ";

scanf("%d" , Choice);
}

Ignore the if (Choice == 2) at the beginning, that's linked to some previous code.

I want to make the player go back to the first bit of text but i'm not sure how to do this if they keep choosing to go back and forth from one location.
I first thought of doing it by just putting the text back in after they have chosen the option, but I can't do this infinite times.

Any help would be great.
closed account (Dy7SLyTq)
functions with static variables
Could you give me an example? I know how to code some stuff but i'm still learning.
try to avoid getting into the habit of using scanf().
1
2
3
4
5
char choice;

...

std::cin >> choice;


Anyway, do you always want the player to go back to the first text? I am having trouble visualizing how you want it to flow.
Thanks for the tip. I don't want the player always going back, just when they select the "Go Back" option.
Bump.
Topic archived. No new replies allowed.