Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

KEYBOARD BUFFER

Status
Not open for further replies.

ARCITS

Programmer
Apr 4, 2002
99
GB
Please see below extract of code.
What I am trying to do is clear the keyboard buffer if the user enters a non numeric value.
Can I clear it all in one go?
Presumably if I can find how much data is in the buffer I can feed this into the first parameter of cin.ignore?
Is the buffer a fixed size. If so could set first parameter of cin.ignore to this. Not very elegant but should work.

Any suggestions greatly appreciated.


Regards




if (!cin.good())
{
cin.clear(); // clear fail bit
cin.ignore(1,'\n');
OptionSelected=10;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top