fork(1) download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. auto x = "foobar"s;
  9. const auto value = "foo"s;
  10. const auto it = search(cbegin(x), cend(x), cbegin(value), cend(value));
  11.  
  12. if(it != cend(x)) {
  13. x.replace(it, next(it, value.size()), crbegin(value), crend(value));
  14. }
  15. cout << x << endl;
  16. }
Success #stdin #stdout 0s 4564KB
stdin
Standard input is empty
stdout
oofbar