fork(4) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. string str = "C:\\user\\asd";
  8. cout << "before: " << str << endl;
  9.  
  10. string::size_type pos = 0;
  11. while ((pos = str.find('\\', pos)) != string::npos)
  12. {
  13. str.replace(pos, 1, "\\\\");
  14. pos += 2;
  15. }
  16.  
  17. cout << "after: " << str << endl;
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0s 4540KB
stdin
Standard input is empty
stdout
before: C:\user\asd
after: C:\\user\\asd