#include#include using namespace std; int main() { // Create a StringBuilder object string str = "Hello World"; StringBuilder sb(str); // Get the length of the string int len = sb.length(); // Print the length cout << "Length of string: " << len << endl; return 0; }
#includeThe StringBuilder class is a part of the C++ standard library and does not require any additional package installation.#include using namespace std; int main() { // Create a StringBuilder object string str = "Hello World"; StringBuilder sb(str); // Iterate over the string for (int i = 0; i < sb.length(); i++) { cout << sb.charAt(i); } return 0; }