#include#include using namespace std; int main() { char buffer[20]; strcpy(buffer, "Hello"); strcat(buffer, " World"); cout << buffer << endl; return 0; }
#includeThis code creates an ostringstream called buffer, which allows us to create a string buffer that can be modified. We then use the << operator to add text and numbers to the buffer, and finally output the contents of the buffer using cout. The StringBuffer data is not actually a part of any external library or package in C++, as it is a built-in class in the std namespace.#include using namespace std; int main() { ostringstream buffer; buffer << "The answer is " << 42 << "."; cout << buffer.str() << endl; return 0; }