Reusing instances of basic_stringstream

A

Andy

I am using basic_stringstream for creating character set neutral
strings.

If I use it like this:

basic_stringstream<wchar_t> str1, str2;

/*1*/ str1<<"A="<<int1<<"; B="<<chr2<<"; C="<<str1<<std::endl;

...

/*2*/ str1<<"D="<<dbl1<<"E="<<flt2<<std::endl;



then after the second set of inserts, what I get is the cumulative
result of the two inserts.
Instead I want each insert to overwrite the previous insert. Any
suggestions.

Cheers,
Andy
 
T

tom_usenet

I am using basic_stringstream for creating character set neutral
strings.

If I use it like this:

basic_stringstream<wchar_t> str1, str2;

/*1*/ str1<<"A="<<int1<<"; B="<<chr2<<"; C="<<str1<<std::endl;

...

str1.str(std::string()); //set the held string to the empty string.

Also, you might need:
str1.clear(); //clears the error state of the stream (if necessary)

Tom
 

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
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top