How do I flush the cin buffer?

I would prefer the C++ size constraints over the C versions:

// Ignore to the end of file
std::cin.ignore(std::numeric_limits<std::streamsize>::max())

// Ignore to the end of line
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n')

Leave a Comment