Writing functions with variable-length argument list
Posted on 2003-02-20
Im looking for a way to pass a variable-length argument list from one function to another.
Let me give an example. Consider the following function header:
void func(char *format, ...);
where "format" is a printf-like format string and the "..." is the argument list that corresponds to the "format" string (as in printf). Now, from this I want to be able to pass these arguments down to the printf/sprintf/fprintf functions. The function "func" would therefore look something like this:
void func(char *format, ...)
// second argument to printf should be the
// variable-length argument list sent to func
I think Ive understood how variable-length argument lists works, but I have not managed to get this to work. My question is therefore: Is this possible? If it is possible, how do I do it?