A variadic C function for concatenating multiple strings
Always return allocated string or never do it

This code here:


if (count &lt; 1)
{
    return "";
}



is bad because you return a static string whereas the normal case returns a string allocated by malloc.  If the caller then tries to free this static string, it will cause some kind of error.  You can fix this by either returning an allocated empty string:

if (count &lt; 1)
{
    return calloc(1, 1);
}


or by just returning NULL:

if (count &lt; 1)
{
    return NULL;
}


Memory leaks

Your function never frees p or len_array.  Actually, I would probably not even use temporary arrays like these.  If I were to write this function, I would measure the total length on one pass, and then copy the strings on a second pass.

Rewrite

After fixing the above issues, my rewrite of your function would look like this:

char *mystrcat(int count, ...)
{
    va_list ap;
    size_t  len = 0;

    if (count &lt; 1)
        return NULL;

    // First, measure the total length required.
    va_start(ap, count);
    for (int i=0; i &lt; count; i++) {
        const char *s = va_arg(ap, char *);
        len += strlen(s);
    }
    va_end(ap);

    // Allocate return buffer.
    char *ret = malloc(len + 1);
    if (ret == NULL)
        return NULL;

    // Concatenate all the strings into the return buffer.
    char *dst = ret;
    va_start(ap, count);
    for (int i=0; i &lt; count; i++) {
        const char *src = va_arg(ap, char *);

        // This loop is a strcpy.
        while (*dst++ = *src++);
        dst--;
    }
    va_end(ap);
    return ret;
}