Jump to content

View more

Image of the Day

Inventory ! Va falloir trouver une autre couleur pour le cadre D: #AzTroScreenshot #screenshotsaturday https://t.co/PvxhGL7cOH
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

Question about std::cin

4: Adsense

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   

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.

#2 SiCrane   Moderators   

11763
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   

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   

220
Like
0Likes
Like

Posted 03 October 2012 - 01:23 AM

Yes

#5 SiCrane   Moderators   

11763
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.