l need help

hello everyone.l am learning c++ on my own and i got confused with "cin.ignore() and cin.clear()".l searched alot on google but end up getting that these two are used to clear buffer again and again.
can anyone please elaborate these two in simple words.
Any help would be appreciated.
The cin.clear() clears any stream error flags.

The cin.ignore() extracts and discards characters from the input buffer. By default it extracts and discards exactly one character.

Normally cin.clear() would first be called then you would ignore() all of the characters in the input buffer using the multi-argument version of ignore() that discards all input upto and including the end of line character.


This site has an API reference that clearly spells out what each of these functions do.

http://www.cplusplus.com/reference/ios/ios/clear/
http://www.cplusplus.com/reference/istream/istream/ignore/
Registered users can post here. Sign in or register to post.