input format error

hi,i need to handle the input error.

my code is like this:
1
2
3
4
5
string name;
int age;

cin >> name;
cin >> age;


If the user input "name" only, without 9, how could i handle this kind of error?
Last edited on
either write a sanitize function, or throw...catch
any more suggestions?
Topic archived. No new replies allowed.