fork download
  1. #include<stdio.h>
  2. #include<string.h>
  3.  
  4. char * doubles(char * s, char c)
  5. {
  6. int cnt = 0;
  7. for(const char * t = s; *t; ++t)
  8. if (*t == c) ++cnt;
  9. char *q = s + strlen(s) - 1,
  10. *t = s + strlen(s) + cnt;
  11. *t-- = 0;
  12. while(q >= s)
  13. {
  14. if (*q == c) *t-- = c;
  15. *t-- = *q--;
  16. }
  17. return s;
  18. }
  19.  
  20.  
  21. int main()
  22. {
  23. char s[40] = "Hello, world";
  24. printf("%s\n",doubles(s,'l'));
  25. }
  26.  
Success #stdin #stdout 0s 5332KB
stdin
Standard input is empty
stdout
Hellllo, worlld