// string::rfind #include #include using namespace std; int main () { string str ("The sixth sick sheik's sixth sheep's sick."); string key ("sixth"); size_t found; found=str.rfind(key); if (found!=string::npos) str.replace (found,key.length(),"seventh"); cout << str << endl; return 0; }