Jump to content
  • Advertisement
Sign in to follow this  
NUCLEAR RABBIT

string input question

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

Hello! i recently finished my little project i was doing, but i have a minor problem. I ask the user for their fav video game, but if the game has multiple words, it counts that as 2 diff game names. Does anyone know how to make it so the user has put spaces in the games name and have it count as one string input?? ex:
string name;

cout << "Game Name: ";
cin >> name

Share this post


Link to post
Share on other sites
Advertisement
Just to add to jfl's post (if I remember correctly) getline leaves the delimiter in the stream, so you will have to strip it out if you want to capture more input after the call

Share this post


Link to post
Share on other sites
Quote:
Original post by CmpDev
Just to add to jfl's post (if I remember correctly) getline leaves the delimiter in the stream, so you will have to strip it out if you want to capture more input after the call


Nope. It is extracted and not stored. (This is usually the behaviour you want.)

Share this post


Link to post
Share on other sites
Quote:
Original post by Zahlman
Quote:
Original post by CmpDev
Just to add to jfl's post (if I remember correctly) getline leaves the delimiter in the stream, so you will have to strip it out if you want to capture more input after the call


Nope. It is extracted and not stored. (This is usually the behaviour you want.)



Rrr that's correct yes. It was get I was thinking off.
Sorry

Share this post


Link to post
Share on other sites
[History]CmpDev may be thinking of Visual c++ 6.0 which had incorrect behavior with std::getline, as laid out in this article.[/History]

Edit: apparently not!

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!