Flush cin
-
Stupid, stupid question. Is there a way to completely flush cin of everything. A '/n' stays in the buffer if you ever use the stream extraction operators. The end goal is to replace the VC6 functionality of 'press any button to continue.' which is written out to the console in debug mode. It needs to be using only STL (using cin / streambufs etc), and it only needs to detect enter being pressed. I know I can use _kbhit(), but I'm annoyed enough to want someone to tell me what I'm missing. Bloody lecturers.
If you can keep you head when all about you Are losing theirs and blaming it on you; If you can dream - and not make dreams your master; If you can think - and not make thoughts you aim; Yours is the Earth and everything that's in it. Rudyard Kipling
-
Stupid, stupid question. Is there a way to completely flush cin of everything. A '/n' stays in the buffer if you ever use the stream extraction operators. The end goal is to replace the VC6 functionality of 'press any button to continue.' which is written out to the console in debug mode. It needs to be using only STL (using cin / streambufs etc), and it only needs to detect enter being pressed. I know I can use _kbhit(), but I'm annoyed enough to want someone to tell me what I'm missing. Bloody lecturers.
If you can keep you head when all about you Are losing theirs and blaming it on you; If you can dream - and not make dreams your master; If you can think - and not make thoughts you aim; Yours is the Earth and everything that's in it. Rudyard Kipling
Try
cin.ignore(numeric_limits::max());
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
Stupid, stupid question. Is there a way to completely flush cin of everything. A '/n' stays in the buffer if you ever use the stream extraction operators. The end goal is to replace the VC6 functionality of 'press any button to continue.' which is written out to the console in debug mode. It needs to be using only STL (using cin / streambufs etc), and it only needs to detect enter being pressed. I know I can use _kbhit(), but I'm annoyed enough to want someone to tell me what I'm missing. Bloody lecturers.
If you can keep you head when all about you Are losing theirs and blaming it on you; If you can dream - and not make dreams your master; If you can think - and not make thoughts you aim; Yours is the Earth and everything that's in it. Rudyard Kipling
In the MFC Library is the following article: HOWTO: Clear an istream Object During Extraction ID: Q132422 INTP
-
In the MFC Library is the following article: HOWTO: Clear an istream Object During Extraction ID: Q132422 INTP
Thanks, that was one of those questions where all the documentation seems to go round in circles, and you never find what you're looking for, but it's working now :-D
If you can keep you head when all about you Are losing theirs and blaming it on you; If you can dream - and not make dreams your master; If you can think - and not make thoughts you aim; Yours is the Earth and everything that's in it. Rudyard Kipling