fork(1) download
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. using namespace std;
  5.  
  6. int main ()
  7. {
  8. char s[100], t[100];
  9. int i, j;
  10.  
  11. cout << "The string is: " << endl;
  12. cin.get (s, 100);
  13.  
  14. strcpy (t, s);
  15. for (i = 0, j = 0; i < strlen (s); i++, j++) {
  16. if (s[i] == 'a') {
  17. strcat (strcpy (s + i, "aa"), t + j);
  18. i += 2;
  19. }
  20. }
  21.  
  22. cout << "The modified string is: " << endl;
  23. cout << s;
  24. }
Success #stdin #stdout 0s 4700KB
stdin
water
stdout
The string is: 
The modified string is: 
waaater