flushing the cin buffer

Is there a simple way to flush the cin buffer for a console app in VC++ 6.
jkelly061597Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
chensuConnect With a Mentor Commented:
::FlushConsoleInputBuffer(::GetStdHandle(STD_INPUT_HANDLE));
0
 
jkelly061597Author Commented:
Sorry, this is beyond my level, do I just say cin::[the rest of it] ?
0
 
chensuCommented:
No, FlushConsoleInputBuffer is a Win32 function. Call it directly as follows.

int main(int argc, char *argv[])
{
    ::FlushConsoleInputBuffer(::GetStdHandle(STD_INPUT_HANDLE));
    return 0;
}
0
 
chensuCommented:
Of course, you should #include <windows.h>.
0
All Courses

From novice to tech pro — start learning today.