Jump to content
  • Advertisement
Sign in to follow this  
Black Knight

Unity istringstream reusing initializing

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

linky Well it was asked long ago and it was unanswered. So what i want to do is : std::istringstream istr; //get a string from an edit box istr.str(myString); istr>>someinteger; //get another string from another editbox istr.str(myString); istr>>anotherInt; I couldn't find a way to do this other than using different istringstreams and creating them with the constructor like std::istringstream istr(myString); Any help?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by dalleboy
Add a call to istr.clear().


Bingo. There isn't a problem with your call to str(string). The internal string object is being updated, but the error bits aren't being reset. clear() does just that.

Share this post


Link to post
Share on other sites
Quote:
Original post by Black Knight
I couldn't find a way to do this other than using different istringstreams and creating them with the constructor like std::istringstream istr(myString);


Well, is it really a problem to do that? Usually this kind of thing happens in a loop, so you can just put this construction at the top of the loop.

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!