How to erase stringstream buffer?

I

Immortal Nephi

I write the information into string stream buffer before cout prints
it to the screen. I would like to reuse the same buffer before I put
new information in it. How do I flush or erase the buffer? The
rdbuf() function is not necessary and where can I use different
function?

std::stringstream ss;
ss << "Hello";
ss << " World!";
std::cout << ss.str() << std::endl;
ss.rdbuf()->str( "" ); // Erase buffer
ss << "Moon";
std::cout << ss.str() << std::endl;
 

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

Forum statistics

Threads
473,967
Messages
2,570,148
Members
46,694
Latest member
LetaCadwal

Latest Threads

Top