Topic: How to 'reset' a strstream?
Author: Chuck Ocheret <chuck@NYC.Thinkbank.COM>
Date: 1998/10/16 Raw View
Is there some way to reset the state of a strstream so that it can
be reused as if it had just been instantiated for the first time.
I'm trying to avoid creating and destroying strstream's repeatedly
by reusing a single strstream.
Here's an illustration of what I want...
...
// Create a single dynamic strstream which
// we'll use multiple times
strstream stream;
for (int i = 0; i < count; i++) {
// Format something (may include spaces, etc...)
stream << foo[i] << bar[i] << baz[i];
// Do something with the formatted info
UseTheFormattedInfo(stream.str());
// *** HERE'S THE PROBLEM
// Somehow reset the stream so it can be reused
// I've tried stuff like this but it seems to have no
effect
s.rdbuf()->freeze(0);
s.rdbuf()->seekoff(0, ios::end, ios::in | ios::out);
}
...
So, is there some magic to do what I want or is there a better way to
do this?
Direct e-mail responses would be appreciated. I'll follow up to the
group.
Thanks,
~chuck
Chuck Ocheret ---------------------------------- chuck@NYC.Thinkbank.COM
Thinkbank, Inc. http://web.Thinkbank.COM/
648 Central Park Avenue, Suite 248 +1 (914) 722-0245 [voice]
Scarsdale, NY 10583 +1 (914) 722-0249 [fax]
[ Send an empty e-mail to c++-help@netlab.cs.rpi.edu for info ]
[ about comp.lang.c++.moderated. First time posters: do this! ]
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]