Are you sure you have the correct input parameters? What's the purpose of the number at the end of the line?
Assuming that the number should be to tell you how many strings to concatenate, I'd expect the number to come first e.g.
2 Rick Manood
3 Hello Rick Manood
11 By the pricking of my thumbs something wicked this way comes
Some thoughts:
1) 50 may be too short for some test cases, you're probably better off using dynamic memory, e.g. malloc()
2) The problem states that you need to concatenate
n strings, not just 2, so you probably want to use a function something like
char *stringCatenate(size_t nargs, const char **strings)
So you'd pass in a counter of the number of strings, and an array of strings, getting back a dynamically allocated string of the strings concatenated together. If you're going to get a
fail
for using
malloc()
(a builtin function - at least for the purposes of this discussion), then you could use a large destination buffer, and then add that as a parameter to stringCatenate e.g.
char *stringCatenate(char *dest, size_t nargs, const char **strings)
Note that any fixed size array has the potential for overflow, leading to unexpected behavior (google "undefined behavior"), but 4K is likely to be enough.