Skip to main content
GameDev.net gamedev.net
🔒 Locked

stringstream clear?

Started by shwig01 Jan 30, 2004 at 5:26 PM 4 replies 1.8k views
Original Post
shwig01
shwig01
Say I have a std::stringstream sstr, and i load some string data into it via the << operator. Now I want to clear that data out, and load new data in. How do I go about clearing out a std:stringstream? clear() and flush() dont work, so im stuck.
-=bPhen=- , what a pity...
SiCrane
SiCrane
Did you try sstr.str(""); ?
Jingo
Jingo
clear() just resets the streams error flags, shouldnt need that unless fail() returns true.
Kylotan
Kylotan
But since many valid operations may end up setting that flag, it''s worthwhile to clear it.
Fruny
Fruny
quote:
Original post by Kylotan
But since many valid operations may end up setting that flag, it''s worthwhile to clear it.


*Nods.*

Like, having reached the end of the string.
"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

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.