You can create IStrings using constructors. You can use IString constructors that construct null strings, that accept a numeric argument and convert it into a string of numeric characters, or that translate one or more characters into an IString. You can also create a single string out of up to three separate buffers, whose contents are concatenated into the created IString object. The following example shows some of the above ways of creating IString objects:
#include <istring.hpp>
#include <&iostreaH.>
void main() {
IString Number1(123); // --> Number1 ="123"
IString Number2(123.12); // --> Number2 ="123.12"
IString Character('a'); // --> Character ="a"
IString String1("a"); // --> String1 ="a"
IString String2("and"); // --> String2 ="and"
IString String3("a\0d"); // --> String3 ="a"
}
Note that the last string (String3) is initialized with only the first byte of quoted text. The null character in the char* constructor argument is interpreted by the compiler as a terminating null. However, the IString class does support null bytes within strings. To construct String3 as the example intended, you could write:
//...
IString String3("and");
String3[2]='\0';
If this string is later copied to another string, the null character and following characters are also copied:
IString String4=String3; String4[2]='N'; // --> String4 ="aNd"