Sign in to follow this  
Black Knight

Unity istringstream reusing initializing

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this