my intension is to have an input that would not accept characters. But for some reason my while loop wont stop to let the try again. It just runs on....
cin>>answer;
while (!isdigit(answer))
{
cout<<"not a number,try again";
cin>>answer;
}
I have a feeling that 'answer' is an int, which can cause problems if you put in a char, and in that case you'll want to do something like this each time through:
1 2 3 4 5
if (cin.fail())
{
cin.clear();
cin.ignore(INT_MAX, '\n');
}