fork(2) download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4.  
  5. int main()
  6. {
  7. std::string hay = "whoknowswhereitisfoobar";
  8. std::string needle = "foo";
  9. auto loc = hay.find(needle);
  10. if ( loc != std::string::npos )
  11. {
  12. std::reverse(hay.begin() + loc, hay.begin() + loc + needle.size());
  13. }
  14. std::cout << hay << std::endl;
  15.  
  16. return 0;
  17. }
  18.  
Success #stdin #stdout 0s 4384KB
stdin
Standard input is empty
stdout
whoknowswhereitisoofbar