str2, which is good.
n2, it is customary to use
size_t as the type, as a hint to other programmers that those are array sizes. Using
int isn't wrong, though.
I suggest returning
result for the caller's convenience.
The purpose of the function is either confused or falsely advertised. C strings are customarily terminated with a null character (
'\0'). If you name your parameter
str…, then I would expect that it relies on such null terminators. On the other hand, you also require the lengths
n2 to be explicitly provided. That looks like more of a memory-copying operation than a string-concatenating operation.
Side note: When some parts of a system work with null-terminated strings, while other parts work with strings of explicit lengths (and which may contain null characters as valid data), the mismatch tends to cause a whole class of bugs, some of which have security implications.
Printing a character at a time is unusual and tedious. A call to
printf("%.11s\n") would be much more convenient than looping.
If you wanted to print a character at a time anyway, then
putchar() would be a simpler function to call.
Declare variables in the tightest scope possible, as late as possible. To another programmer encountering your code, the
int i, j declaration at the top is meaningless. On the other hand,
for (int i = 0; i < n1; ++i)
makes it clear that
i is a counter that is only used in that loop.
Always write your blocks and loops with the optional braces. By omitting the braces, you are contributing to a future coding accident.