#include<stdio.h>
#include<string.h>

char * doubles(char * s, char c)
{
    int cnt = 0;
    for(const char * t = s; *t; ++t)
        if (*t == c) ++cnt;
    char *q = s + strlen(s) - 1,
         *t = s + strlen(s) + cnt;
    *t-- = 0;
    while(q >= s)
    {
        if (*q == c) *t-- = c;
        *t-- = *q--;
    }
    return s;
}


int main()
{
    char s[40] = "Hello, world";
    printf("%s\n",doubles(s,'l'));
}
