BString str; char charArr[] = "Hello, world!"; str.SetTo(charArr);
BString str; str.SetTo("Constant string value");
BString str("This is a long string"); str.SetTo(str.String(), 4, 2);This code creates a BString object, `str`, with the value `"This is a long string"`. The SetTo method is then used to assign a substring of `str` to `str`. The substring starts at the 4th character and has a length of 2 characters, resulting in `is` being assigned to `str`. Package library: BeOS/Haiku API.