Restart If

I dont want to use a ton of while statments so is there a way if in its else statement to restart. Or to restart it before the command is enterd. I enter commands like this cin >> aclass; and the use an if to check it..(to learn C++ im making a small text based game).
No, but you probably should be making a function that reads some user input and validates it.
ok
Not that I've understood anything of your question, but it could be as simple as:
1
2
3
4
5
6
7
8
void checkedCin (int& aclass){
do{
cin.clear();
cin.ignore (100);
cout << "Enter a number";
cin >> aclass;
}while (cin.fail());
}

Just guessing, cause I really don't understand your question at all...
Last edited on
Topic archived. No new replies allowed.