Link to home
Start Free TrialLog in
Avatar of realchick
realchick

asked on

Single Most Efficient Way to Clear Keyboard Buffer C++

Hi All,

Can someone please tell me the single most efficient way to clear the keyboard buffer in C++?  I found the following but don't know if it's efficient:

cin.ignore(numeric_limits<streamsize>::max(), '\n');

Some background:  I'm a college student in 1st Semester OOP.

- Thanks
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of realchick
realchick

ASKER

Good, I'm going to post this to my classroom discussion.  Out textbook doesn't mention "numeric_limits" or even cin.clear()...so I struggled to find a good input validation solution online and my while loop just ran for miles and miles!