Inserção de string em outra string

// Insert q char c in pos n of the string str.
int strinsert(char **str, char c, int  n, int q)
{
    int len = my_strlen(*str);
    char ins[q + 1];
    char *new = malloc(len + q + 1);

    memset(ins, c, q);
    memset(new, 0, len + q);
    ins[q] = '\0';
    strncpy(new, *str, n);
    new[n] = '\0';
    strcat(new, ins);
    strcat(new, *str + n);
    return (0);
}

strinsert(&str, 'X', strlen(str) / 2, 5);
// Inserting in string str 5 'X' in the middle of the string
Grumpy Gentoo