How to clear the buffer for istreams?
Hi,
what if I want to read only one character of input from the keyboard and want to use streams? so this:
will read a character plus any other garbage the user entered. To clear the buffer I must now do this:
1 2
|
string str;
getline(cin, str);
| |
Is there a cleaner one instruction way that would discard the values in the buffer?
Topic archived. No new replies allowed.