// IBM Open Class (IOC) Library // Example of IString class - AIX specific // Compile: xlC_r -lcxxbase StringTest.cpp // Greg Ippolito // Documentation: /usr/ibmcxx/html/en_US/doc/index.html // Include files found in: /usr/ibmcxx/include/... #include #include #include main() { IString a="abcd efg"; // IString has various constructors IString b("xyz ijk"); IString c, d(3.1415926); // Type conversion constructor IString e(" Leading and trailing blanks "); cout << a << " " << b << endl; c = a + b; // concatenation cout << c << endl; cout << "String length: " << c.length() << endl; cout << "Conversion from float to string: " << d << endl; c = d; cout << "Copy string: " << c << endl; cout << "First character: " << c[1] << endl; // IStrings start with 1 NOT 0 cout << c.rightJustify(20) << endl; cout << c.center(20) << endl; cout << "X" << e.stripLeading() << "X" << endl; cout << "X" << e.stripTrailing() << "X" << endl; IString f(" Leading and trailing blanks "); cout << f << endl; cout << f.strip() << endl; cout << "The letter 'd' first occurs at position " << f.indexOf('d') << endl; I0String g(3.1415926); cout << "First character: " << g[0] << endl; // I0Strings start with 0 } /* abcd efg xyz ijk abcd efgxyz ijk String length: 15 Conversion from float to string: 3.1415926 Copy string: 3.1415926 First character: 3 3.1415926 3.1415926 XLeading and trailing blanks X XLeading and trailing blanksX Leading and trailing blanks Leading and trailing blanks The letter 'd' first occurs at position 4 First character: 3 */