Inserting a parenthesized nickname
Naming

Your variable names are polyglot, cryptic, and inconsistent.  Don't mix Italian with English — stick with English if you can.  Instead of s1…s3, pick more meaningful names.  Instead of p, q, and k, it would have been better to use p1, p2, and p3 — but again, more meaningful names would be even better.

Function signatures

In modern C, you should mark strings as const if you're not going to write to them.

It is customary to put main() at the end, so that you don't need to declare your functions.

Approach

You aren't writing a '\0' terminator character to out, so your function won't work if the buffer is unclean.

Your solution is not robust to unexpected input, such as extra spaces at the end of s1.

Character-by-character manipulation isn't very readable.  You wouldn't want to write code like this in a larger project.  Instead, make use of the existing library functions for working with strings.  (You have already written #include &lt;string.h&gt;, so why not?)

char *makeNickname(const char *names, const char *nickname, char *out) {
    const char *firstSpace = strchr(names, ' ');
    const char *lastName = firstSpace + strspn(firstSpace, " ");
    sprintf(out, "%.*s (%s) %s", (int)(firstSpace - names), names, nickname, lastName);
    return out;
}


Note that this solution, like yours, doesn't check for buffer overflow.  It would be good practice to also pass the size of the buffer to enable such a check.