Hi everyone I need tome tips because I'd to learn how to create a validation process, I want the program to only take int variables, and if the user write something else, there is a pront that tell to try again but whenever I try to to it it's just go automatically to infinite loop, let me get you an example
int grades;
cout << "Write the grades" << endl;
// if the user write a letter or something else I want to promt that need it to write something again, i wish I can do it with funtion isalpha() but I try it and I guess I just don't know how to use it.
// the way a try it
cin >> grades;
while(grades != 0)
{
cout << "Try again" << endl;
cin >> grades;
}
Something else I'd like to know if you don't mind if that I'm trying to repeat a code as well but when I try to do it, it's skipping the first part and I don't know why, still running though but just that, this is an example
#include <iostream>
#include <string>
using namespace std;
int main()
{
char repeat;
do {
int age;
string fullname;
cout << "enter your full name" << endl;
getline(cin, fullname);
cout << "enter your age" << endl;
cin >> age;
cout << "\n \n \n";
cout << fullname << endl;
cout << age;
cout << "\n \n";
cout << "press (y) to repeat" << endl;
cin >> repeat;
}while(repeat == 'y');
return 0;
}
/* i know is a little messy but it is just an example, I've been working with it for a few hours but I can't figure it out I guess THANK YOU IN ADVANCE!!*/