I have some problem with following code. I use it in Xcode (OS X).
[removed my first try of that code]
How to input reset std::cin? I try to input another va
You could use, when the condition, std::cin.fail()
happens:
std::cin.clear();
std::cin.ignore();
And then continue with the loop, with a continue;
statement. std::cin.clear()
clears the error flags, and sets new ones, and std::cin.ignore()
effectively ignores them (by extracting and discarding them).
Sources: