RT. Typically, the string stream has its own buffer.
std::ostringstream stream;
stream << "Hello";
stream.str(); // It's "Hello"
Then how to redirect the buffer inside the string stream to my own allocated memory like this,
std::string *buffer = new std::string;
std::ostringstream stream;
stream.rdbuf( buffer );
stream.str(); // It's "Hello"
buffer->c_str(); // It's also "Hello"