// A sample program showing the use of a string object and the // associated library functionality // // Author: Michael H. Goldwasser // Date: 28 January 2005 #include // we wish to use input/output streams #include // we wish to use the string library using namespace std; // Makes parts of the above libraries more easily accessible int main() { string name = "Saint Louis University"; cout << "The size of " << name << " is " << name.size() << endl; cout << "The result of name.substr(6,5) is \"" << name.substr(6,5) << "\"" << endl; string pattern; pattern = "Lou"; cout << "A call to name.find(pattern) where pattern is \"" << pattern << "\" returns " << name.find(pattern) << endl; pattern = "lou"; cout << "A call to name.find(pattern) where pattern is \"" << pattern << "\" returns " << name.find(pattern) << endl; pattern = "t"; cout << "A call to name.find(pattern) where pattern is \"" << pattern << "\" returns " << name.find(pattern) << endl; pattern = "t"; cout << "A call to name.find(pattern,10) where pattern is \"" << pattern << "\" returns " << name.find(pattern,10) << endl; }