fork(1) download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main ()
  7. {
  8. string s;
  9.  
  10. cout << "The string is: " << endl;
  11. cin >> s;
  12.  
  13. string::size_type pos = 0;
  14. do {
  15. pos = s.find('a', pos);
  16. if (pos == string::npos) break;
  17. s.replace(pos, 1, "aaa");
  18. pos += 3;
  19. }
  20. while (true);
  21.  
  22. cout << "The modified string is: " << endl;
  23. cout << s;
  24. }
Success #stdin #stdout 0s 5040KB
stdin
water
stdout
The string is: 
The modified string is: 
waaater