Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Question about std::cin


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
4 replies to this topic

#1 jdub   Members   -  Reputation: 459

Like
0Likes
Like

Posted 02 October 2012 - 04:44 PM

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?
J.W.

Sponsor:

#2 SiCrane   Moderators   -  Reputation: 10724

Like
0Likes
Like

Posted 02 October 2012 - 04:50 PM

Are you using the >> operator to get input or one of the getline() functions?

#3 jdub   Members   -  Reputation: 459

Like
0Likes
Like

Posted 03 October 2012 - 01:20 AM

the operator >>. Should I be using getline()?
J.W.

#4 game of thought   Members   -  Reputation: 218

Like
0Likes
Like

Posted 03 October 2012 - 01:23 AM

Yes

#5 SiCrane   Moderators   -  Reputation: 10724

Like
1Likes
Like

Posted 03 October 2012 - 05:08 PM

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.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS