fork(1) download
  1. // string::rfind
  2. #include <iostream>
  3. #include <string>
  4. using namespace std;
  5.  
  6. int main ()
  7. {
  8. string str ("The sixth sick sheik's sixth sheep's sick.");
  9. string key ("sixth");
  10. size_t found;
  11.  
  12. found=str.rfind(key);
  13. if (found!=string::npos)
  14. str.replace (found,key.length(),"seventh");
  15.  
  16. cout << str << endl;
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
The sixth sick sheik's seventh sheep's sick.