variable argument list for string concatenation
Hey all...i've been working at this C programming since Feb 2018, currently using clang on freebsd 11.2. I am the second time through a 700 page book, only 2 more lessons left, then I hope to move onto K&R 2nd editon ANSI-C. Quick question, please give me some clues toward working on my current question & answer on Lesson 19 out the my text i'm working on....
"write a function that is (a) passed a number of strings as arguments, (b) concentates the strings, into one longer string, and (c) returns a pointer to the new string to the calling program".
I am familiar with:
Code:
int func_1(int num, ...)
is always going to be an integer, and was confused about maybe using a char array in the function prototype. And also, i was kind of thinking to assign each string (i.e. string_1 & string_2) to an integer so I could pass it to the function like this:
Code:
char c;
c = func_1(1);
But wasn't sure how to do this. I have googled "variable argument list", understand (to an extent) how to use the macros in a program, and also have been re-reading the material in my text.
Pseudo-code helpful. Thanks!