#include #include using namespace std; const string count0 ="0 1 2 3"; const string count1 ="012345678901234567890123456789012"; const string pattern="Now is the time for all good men"; void print_loc(string source, string pat); int main () { string::size_type pos; string find; cout << "The string is " << endl; cout << count0 << endl; cout << count1 << endl; cout << pattern << endl; pos = pattern.find('g'); cout << "'g' is at position " << pos << " in the string" << endl; pos = pattern.find("time f"); cout << "\"time f\" is at position " << pos << " in the string" << endl; print_loc(pattern,"time f"); find="time f"; print_loc(pattern,find); find = "Hello"; print_loc(pattern,find); return(0); } void print_loc(string source, string pat) { string::size_type place; place = source.find(pat); cout << "\"" << pat << "\" is at position " << place << " in the string" << endl; }