#include#include using namespace std; int main() { StringBuilder sb; sb.append("Hello "); sb.append("World!"); string str = sb.toString(); cout << str << endl; return 0; }
#includeThis example shows how StringBuilder can be used inside a loop to generate a string with numbered items delimited by a space. The StringBuilder class is not a standard part of the C++ library, so it must be included as a dependency. The package or library that provides StringBuilder can vary depending on the environment or framework being used. In some cases, it may be part of a third-party library or toolkit that provides additional functionality for string manipulation.#include using namespace std; int main() { StringBuilder sb; for (int i = 0; i < 10; i++) { sb.append(to_string(i) + " "); } string str = sb.toString(); cout << str << endl; return 0; }