how to clear a sstreeam object

C

Charles Herman

I create a ostringstream object, and use it to write to. After having done
this, I want to re-use it, but first I need to clear out all characters in
it. How do I do this?

-charles
 
M

Mike Wahler

Charles Herman said:
I create a ostringstream object, and use it to write to. After having done
this, I want to re-use it, but first I need to clear out all characters in
it. How do I do this?

ostringstream oss;
oss << "blah";
oss.str("");

-Mike
 
F

Frank Schmitt

Charles Herman said:
I create a ostringstream object, and use it to write to. After having done
this, I want to re-use it, but first I need to clear out all characters in
it. How do I do this?

use the str() member function:

ostringstream os;
os << "bla";
os.str(""); // assign empty string to os

HTH & kind regards
frank
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,142
Messages
2,570,820
Members
47,367
Latest member
mahdiharooniir

Latest Threads

Top