how to clear a stringstream object in stl????

Started by
18 comments, last by ByteMe95 21 years, 10 months ago
Ive looked to the vast reaches of the itnernet and from what I have seen there is practically absolutely no way to clear a stringstream object!!! How is that possible? Say i have a stringstream object A, and i use it in a loop. At the beginning of every loop I want to clear A so it doesnt accumulate when I extract the string wtih A.str() FRom what ive seen there is no way to clear the buffer, the only solution i have come up wtih is to declare A as a pointer and do A = new stringstream; before the use and delete A after the use is there no better way? ByteMe95::~ByteMe95() My S(h)ite
ByteMe95::~ByteMe95()My S(h)ite
Advertisement
Umm. I might be wrong but are you allowed to:

stringstream ss;//fill ss with junkss = ""; 


Then again maybe I''m out to lunch on this one...
Just because the church was wrong doesn't mean Galileo wasn't a heretic.It just means he was a heretic who was right.
Atavist: You''re right : ss = ""

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
As above, ss = "";
I asked the same question about ss = "";
It just seems wrong that there''s no clear method.
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
quote:Original post by Magmai Kai Holmlor
It just seems wrong that there''s no clear method.


doesn''t iostream::clear clears the stream io flags ?

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
ss = "" produces compiler errors, i guess you cant do that with stringstreams

ByteMe95::~ByteMe95()
My S(h)ite
ByteMe95::~ByteMe95()My S(h)ite
quote:Original post by ByteMe95
ss = "" produces compiler errors, i guess you cant do that with stringstreams


We''re talking about std::stringstream, not strstream, right ?


Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan
i am using stringstream yes
dont really know what strstream is or what the differences are

ByteMe95::~ByteMe95()
My S(h)ite
ByteMe95::~ByteMe95()My S(h)ite
Maybe try
ZeroMemory(stringObj, sizeof(StringStream))
This may work, or it may casuse your computer to freeze, I don''t know, use at your own risk.
Checking my book : ss.str("");

Forget I ever mentioned strstream (pre-standard string stream)

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." — Brian W. Kernighan

This topic is closed to new replies.

Advertisement