Hello, this is my first post so be nice :)
After hours of trolling various forums and websites along with a few books i've decided to ask for help. I've put together the whole of the program which is to carry out a few simple processes using inputted data and display the number in word form (i've done that bit).
The problem is when im testing on extronus data (in the case letters) it hits an infine loop. So i would like to have validation in to stop this from happening, as i have done with the values if they're too big or too small.
From current research i've found isdigit and using:
cin.ignore(numeric_limits<int>::max(), '\n');
if(!cin || cin.gcount() != 1);
with no luck. I'll paste a function out of my code and if you could point me in the right direction that would be perfect. I've got all the correct libaries and used all the correct libaries when attempting to use the last two. Also any varibles involved in this function are global.
void inputweeks(){
while(weeks < 4 || weeks > 5)
{cout << "Enter amount of weeks in the month (4 or 5): ";
cin >> weeks;
if(weeks < 4 || weeks > 5)
{cout << "!ERROR!! this is an inncorrect input" << endl;
}}
}
Kind Regards
A