Archived

This topic is now archived and is closed to further replies.

Simple Question about cin.get();

This topic is 5278 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Just so I fully understand... when cin.get() requests a character (or string) from the inpput buffer and the buffer is empty, it waits for new input and only then does it continue its execution.

Share this post


Link to post
Share on other sites
i only recently learned about cin.get cause im finnaly gettin on track to programming...but.....ive been taught to either add a cin.ignore(9999,''\n''); then a cin.get(); or two cin.get();s because the buffer is not empty usually...the last enter keypress should still be there...so its safer to add 2 or the ignore....thats probably not even two vcents....but it might help

Share this post


Link to post
Share on other sites
Yeah cin.get() doesn''t read in the newline character so that will be left and picked up by your next cin call.

You can use (cin.get()).get() since cin.get() returns a cin object.

Share this post


Link to post
Share on other sites