AnsiString str("Hello"); str.SetLength(10); str = str + " World!"; cout << str; // output: "Hello World!"
AnsiString str("Goodbye"); str.SetLength(3); cout << str; // output: "Goo"This example creates an AnsiString object with the value "Goodbye". The SetLength method is used to shorten the length of the string to 3, resulting in "Goo". The AnsiString class and SetLength method are part of the System.Classes package in the C++ Builder library.