Halp

closed account (Dj15fSEw)
I made a selection menu through text for an rpg, and need a way to say, - if the input the user gave didnt match the list of possible inputs, "error", and loop to the beggining of the program.
A simple input validation loop :
1
2
3
4
5
6
7
8
9
while( true ) {
   string in;
   cout << "Enter a string\n";
   getline( cin, in );
   if( in == "a string" ) {
      //do stuff
      break;
   }else cout << "This is not a string\n";
}
Topic archived. No new replies allowed.