By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,389 Members | 1,844 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,389 IT Pros & Developers. It's quick & easy.

Reusing instances of basic_stringstream

P: n/a
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
Jul 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 20 Nov 2003 05:00:43 -0800, ga***********@yahoo.com (Andy) wrote:
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
Jul 22 '05 #2

P: n/a
Thanks. I overlooked your answer to another post with the same question.

tom_usenet <to********@hotmail.com> wrote in message news:<1l********************************@4ax.com>. ..
On 20 Nov 2003 05:00:43 -0800, ga***********@yahoo.com (Andy) wrote:
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

Jul 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.