0
How to combine multiple lines into one line in c?
Example1: Input: I want to eat an apple. Output: I want to eat an apple. Example2: Input: I want to meet my mother and father. Output: I want to meet my mother and father.
2 Answers
0
Basically you want to merge 3 strings, so prepare a result buffer (char array) big enough to contain the 3 strings, the spaces in between, and one null character for string terminator.
Then you can use strncat() function from <string.h> to copy the 3 strings content into the result buffer. You can make use of a loop in case there are many strings to be merged e.g. when the strings to be merged are array elements.
http://www.cplusplus.com/reference/cstring/strncat/