How to Flush standard input?
Hi!
Iīm trying to fulsh standard input - all though this seems not possible to me. My code is:
Code:
bool exit_status;
char current;
exit_status=false;
while(!exit_status){
cin.clear();
cin >> current;
switch(current){
case 'p':
// do something
break;
case 'u':
// do something
break;
case 's':
// do something
break;
default:
cout << "Unkown command" << endl;
}
}
When I run this, I donīt expect when typing: "pussy", that the program runs the functions ascossiated with p,u,s,s and types "Unkown command"....
Anyone knows how to flush the inputstream so that only function p will be run???