If/Switch statement that always runs

Oct 21, 2011 at 10:03pm
I am making a project, and there are multiple areas in the project where the user enters something, but every time I want it to check for something. Is there a way to make an if or switch statement that will always run for every cin >> ?
Oct 21, 2011 at 10:07pm
Make it a function, and call it every time you use cin.
Good luck!
Oct 21, 2011 at 10:40pm
Thanks!
Oct 22, 2011 at 2:37am
Actually, you could include cin in your function:

1
2
3
4
5
bool checkSomething(int &var){
    cin >> var;
    if (???) return true;
    else return false;
}


Assuming every cin acts on the same variable type.
Topic archived. No new replies allowed.