#include#include using namespace std; int main() { // Create a StringBuilder object stringstream str; str << "Hello "; // Append a string to the existing string str << "World!"; // Print the final string cout << str.str() << endl; // Output: Hello World! return 0; }
#includeThe StringBuilder class is part of the C++ standard template library.#include using namespace std; int main() { // Create a StringBuilder object stringstream str; str << "Hello World!"; // Iterate over each character in the string and replace 'o' with '0' for (int i = 0; i < str.str().length(); i++) { if (str.str()[i] == 'o') { str.str()[i] = '0'; } } // Print the final string cout << str.str() << endl; // Output: Hell0 W0rld! return 0; }