next up previous index
Next: STL vectors and Up: Standard Template Library Reference Previous: STL include files

STL example programs

  Some of these examples also use string handling facilities in mstring.h. STL does not provide any special facilities for dealing with strings. Comprehensive STL-based string libraries are under development; in the meantime, mstring.h provides a simple STL-based set of string facilities. mstring.h provides three string types: string, alpha, and line. These all have all the usual vector member functions (each is publicly derived from vector<char>); they differ just in the way that input works (as defined by istream operator<<).

In each case a null character is appended, and the member function chars returns a pointer to the first character, so that conventional string handling functions such as strlen can be applied, as in

    string s("abc");
    cout << strlen(s.chars()) << endl;    // outputs 3
    cout << s.size() << endl;  
         /* size is the vector member function, 
            outputs 4 since null character is counted */

The mstring.h header file resides in the same directory as the STL header files.





Kenny Zalewski
Mon May 13 04:03:40 EDT 1996