clearing cin input? cin.ignore not a good way?
- by igor
What's a better way to clear cin input? I thought cin.clear and cin.ignore was a good way...?
code:
void clearInput()
{
cin.clear();
cin.ignore(1000,'\n');
//cin.ignore( std::numeric_limits<streamsize>::max(), '\n' );
}
My teacher gave me this reply...
this is basically saying that your
clearInput doesn't work FYI: ignore
is NEVER a good idea as a way of
getting rid of all that remains on a
line
and your failing this test is exactly
the reason why now go clear it the
correct way