• Advertisement
Sign in to follow this  

Question about std::cin

This topic is 1934 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

When I use std::cin to get input and enter a space after the input, it seems that the next cin statement is skipped. What is going on here and how do I get around this?

Share this post


Link to post
Share on other sites
Advertisement
Are you using the >> operator to get input or one of the getline() functions?

Share this post


Link to post
Share on other sites
It's not a matter of one being strictly better than the other. It's just that operator>> doesn't work how many people think it works. Specifically, after it reads what it wants to, it generally leaves stuff in the buffer that people don't think to get rid of before they do the next read. Depending on what types you're trying to read, doing so could be either very important or completely unnecessary.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement