By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,433 Members | 1,276 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,433 IT Pros & Developers. It's quick & easy.

Need reference for stringstream

P: n/a
clb
I am trying to use stringstreams and my book doesn't cover the included
methods. For example, if I init a istringstream on a string and suck all
the data out, then put more stuff into the string, how do I reset the
ISS to see the new data? Does this make sense?

May 29 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
On May 28, 8:30 pm, clb <c...@earthlink.netwrote:
I am trying to use stringstreams and my book doesn't cover the included
methods. For example, if I init a istringstream on a string and suck all
the data out, then put more stuff into the string, how do I reset the
ISS to see the new data? Does this make sense?
You can start with the Apapche C++ Standard Library online
documentation,
the chapter on string streams in the User's Guide:
http://incubator.apache.org/stdcxx/doc/stdlibug/31.html

May 29 '07 #2

P: n/a
On 29 Maj, 04:30, clb <c...@earthlink.netwrote:
I am trying to use stringstreams and my book doesn't cover the included
methods. For example, if I init a istringstream on a string and suck all
the data out, then put more stuff into the string, how do I reset the
ISS to see the new data? Does this make sense?
You have to put the new content into the stringstream, depending on
your needs it might be as simple as to use the << operator to output
the string to the stringstream. Notice that the string you specified
in the ctor is not used as buffer for the stringstream, only
initialization. Check this site out for more information:
http://www.cplusplus.com/reference/i...ingstream.html

--
Erik Wikström

May 29 '07 #3

P: n/a

clb <cl***@earthlink.netwrote in message
news:46***************@earthlink.net...
I am trying to use stringstreams and my book doesn't cover the included
methods. For example, if I init a istringstream on a string and suck all
the data out, then put more stuff into the string, how do I reset the
ISS to see the new data? Does this make sense?
First, use 'MySs.clear();' to reset any 'fail flags' on the stream.
Then you can empty the stream by doing:
MySs.str("");

.... or, re-use it:
MySs.str("Hello world!");

Actually, you don't 'suck all the data out'. Try an experiment; set your
istringstream, 'suck all the data out', then try:
MySs.clear();
MySs.seekg(0); // assumes an std::[i]stringstream
..... then try 'reading' it again.
What happens?

[ correctios, as always, are welcome. ]
--
Bob R
POVrookie
May 29 '07 #4

P: n/a

Erik Wikström wrote in message...
/* """
On 29 Maj, 04:30, clb <c...@earthlink.netwrote:
I am trying to use stringstreams and my book doesn't cover the included
methods. For example, if I init a istringstream on a string and suck all
the data out, then put more stuff into the string, how do I reset the
ISS to see the new data? Does this make sense?
You have to put the new content into the stringstream, depending on
your needs it might be as simple as to use the << operator to output
the string to the stringstream. Notice that the string you specified
in the ctor is not used as buffer for the stringstream, only
initialization. Check this site out for more information:
http://www.cplusplus.com/reference/i...ingstream.html
- - Erik Wikström
""" */

Hi Erik,

<cough><chokea '<<' on an std::istringstream'? <G>
(the OP mentioned 'istringstream', so thought I'd poke a little fun.)

Actually, I'm only (re)posting to mention to the OP that Dinkumware has some
documentation too. [ I forgot to put that in my other post]

--
Bob R
POVrookie
May 29 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.