I have a function currently that reads one integer, and checks for errors (too big too small or not an integer.
int be_egesz(string question, int minval, int maxval, string error_message)
{
bool error;
string tmp;
int number;
do
{
cout << question << endl;
cin >> szam;
error=cin.fail() || cin.peek()!='\n' || (number<minval || number>maxval);
if (error)
{
cout << error_message << endl;
}
cin.clear();
getline(cin,tmp,'\n');
}while(error);
return number;
}
How can I transform this function, so that it can read more than 1 integer in one line?
Example input: 1 2
Or maybe how can I use this function 2 times for one line