Skip to main content
gamedev.net
🔒 Locked

Clearing a std::stringstream?

Started by Jeff Leigh Sep 25, 2002 at 4:14 PM 3 replies 900+ views
Original Post
Jeff Leigh
Jeff Leigh
Hi, For the sake of sounding incredibly stupid and having that stupidity forever archived on gamedev... How do I clear a stringstream? As far as I can tell, my C++ reference completely omits it. I tried:
std::stringstream Buffer;

for( Counter_1 = Child_Count - 1; Counter_1 >= 0; Counter_1 -- )
{
     Buffer << "[" << Counter_1 << "]";
     EAP_Memory.Destroy( Buffer.str() );
     Buffer.flush();
}
   
But this seems to have the effect of absolutely nothing . Destroy gets called subsequently with "[4]", "[4][3]", "[4][3][2]", etc. Ah the joys of converting a char* program to use the string class... - Jeff Leigh Enygma Arts [edited by - Jeff Leigh on September 25, 2002 5:14:57 PM] [edited by - Jeff Leigh on September 25, 2002 5:16:00 PM]
Jeff LeighEnygma Arts
Oluseyi
Oluseyi
Buffer(""); 

Counterintuitive and stupid. But that''s how it''s done.
DrPizza
DrPizza
It is.

You clear the string:
Buffer.str("");
and you clear the flags:
Buffer.clear();

And it is a horrid bit of ugliness.
char a[99999],*p=a;int main(int c,char**V){char*v=c>0?1[V]:(char*)V;if(c>=0)for(;*v&&93!=*v;){62==*v&&++p||60==*v&&--p||43==*v&&++*p||45==*v&&--*p||44==*v&&(*p=getchar())||46==*v&&putchar(*p)||91==*v&&(*p&&main(0,(char**)(--v+2))||(v=(char*)main(-1,(char**)++v)-1));++v;}else for(c=1;c;c+=(91==*v)-(93==*v),++v);return(int)v;} /*** drpizza@battleaxe.net ***/
Shannon Barber
Shannon Barber
quote:
Original post by Jeff Leigh
How do I clear a stringstream?


I think everyone that uses it, ask how to clear it.
One would anticipate .clear - but that''s a container concept, and this is a stream.
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

Topic Locked

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

Sign in to reply to this topic.