ostringstream

J

James Madison

How do I purge an ostringstream object?

I put some strings into it, but I want to print it, purge it, and put different strings in it, print it, etc.

How do I do that without using a pointer and new/delete?

James
 
J

Jim Fischer

James said:
How do I purge an ostringstream object?

I put some strings into it, but I want to print it, purge it, and put
different strings in it, print it, etc.

Load an empty string "" into it:

ostringstream out;
...
out.str("");
 
G

Grzegorz Sakrejda

------=_NextPart_000_00CF_01C35B6E.F2852C90
How do I purge an ostringstream object?

I put some strings into it, but I want to print it, purge it, and put
different strings in it, print it, etc.

How do I do that without using a pointer and new/delete?

James


os.rdbuf()->seekpos(0,ios::eek:ut);

Note: an open mode argument which determines position of the put pointer.

grzegorz
 

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,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top