How do I clear the cin buffer in C++?
Easiest way:
cin.seekg(0,ios::end); cin.clear();
It just positions the cin pointer at the end of the stdin stream and cin.clear() clears all error flags such as the EOF flag.