12345678910111213
char resp; while (true) { cout << "Do you want to do something? (y|n) "; cin >> resp; if (resp=='n') break; if (resp=='y') { /*do something*/ break; } cout << "\n\nInvalid response!\n"; }