Text adventure game, how to make loop

If the user inputs something other than 'a' or 'A'. Then it will simply ignore it and wont output the cout statement. How do i make it so that if the user doesn't input 'A' or 'a'. it loops back and asks the user to enter 'A' or 'a'. and repeat until the user does.

[code]
cout << "You awaken in the middle of a forest... fully naked." << endl;
cout << "Press 'A' then enter to look around." << endl;

char userInputA;
cin >> userInputA;

if (userInputA == 'a' || userInputA == 'A')
{
cout << "You search around for any clues as to where you are." << endl << "In the distance you are able to see gray smoke" << endl;
}




Lol this is untested but I been working on using these kinds of expressions more.

1
2
3
4
5
6
7
8
9

While(cin.get() != 'a' | 'A' ? True : False && SomeFunc();)
{  //user didn't enter a

}
Void SomeFunc(){

//User entered a
}
Last edited on
Topic archived. No new replies allowed.