strstream was a mistake just pretend it doesn''t exist.
ss.str().clear()?
ss.clear_str()?
ss.str_clear()?
how to clear a stringstream object in stl????
wow, ive never seen so many replies so fast! thanks everyone
There was only one correct answer to my question, and the answer is.... drumroll please.......
ss.str("")!!
thanks fruny
thanks again to everyone else for trying
- Rob
ByteMe95::~ByteMe95()
My S(h)ite
There was only one correct answer to my question, and the answer is.... drumroll please.......
ss.str("")!!
thanks fruny
thanks again to everyone else for trying
- Rob
ByteMe95::~ByteMe95()
My S(h)ite
"I could never have done it without my books. And I want to thanks my parents without whom I wouldn''t be here today..."
Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
ss.clear();
The above works for me(using VS .NET and its own STL library), it empties a stringstream object.
The above works for me(using VS .NET and its own STL library), it empties a stringstream object.
quote:Original post by Ziphnor
ss.clear();
The above works for me(using VS .NET and its own STL library), it empties a stringstream object.
Erm... no it doesn''t, it clears the stream''s status flags, as Fruny said earlier. Do pay attention!
[ C++ FAQ Lite | ACCU | Boost | Python | Agile Manifesto! ]
ziphnor, i find it funny that you said .clear() worked for you when all logic dictates it shouldnt, so did you actually TRY it and it did in fact work, or were you just assuming it would?
ByteMe95::~ByteMe95()
My S(h)ite
ByteMe95::~ByteMe95()
My S(h)ite
I find it''s usually best to use the .str("") and the .clear() methods together, as that should ensure a virtually fresh stringstream.
[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files ]
[ MSVC Fixes | STL | SDL | Game AI | Sockets | C++ Faq Lite | Boost | Asking Questions | Organising code files ]
struct mystringstream : std::stringstream { void clear() { this->str(""); this->std::stringstream::clear(); } };
quote:
ziphnor, i find it funny that you said .clear() worked for you when all logic dictates it shouldnt
Im not a complete idiot you know
In my code i use a stringstream in some string to value conversions, sometimes i had a problem with the stringstream containing some garbage after retrieving the value.
Using clear solved that problem, but when i think about it, this might have been due to some error during a conversion that was reset by clear....( i thought the garbage was leftover stuff from the previous strings added to the stringstream).
So the situation is not the same at all, i apologize.
Just tested it, and neither clear() or flush() empties the stringstream, but ss.str("") does....
Again, im sorry if i mislead anybody.
[edited by - ziphnor on June 11, 2002 2:19:18 PM]
its all good ziphnor, I thank you for trying to help
this is like the never ending post
ByteMe95::~ByteMe95()
My S(h)ite
this is like the never ending post
ByteMe95::~ByteMe95()
My S(h)ite
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement