So I was doing some code for input validation on my homework program and i have the correct code to make sure a number entered it correct but I thought, what if they enter a letter. We aren't required to make sure that the user entered a number but how would i do that?
Here is what I have right now:
cout << "\tAge(yrs.): ";
cin >> age;
/*
Makes sure age is above 0 years. If not, user
goes through a while loop until they enter an
appropriate value.
*/
while(age<=0){
cout << endl
<< "You did not enter a corect age in years! "
<< "Please re-enter your age -- " << endl;
cout << endl << "\tAge(yrs.): ";
cin >> age;
}