istringstream reusing initializing
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?
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement