How can I write a function which takes a variable number of arguments and passes them to some other function (which takes a variable number of arguments)?
In general, you cannot. You must provide a version of that other function which accepts a va_list pointer, as does vfprintf in the example above. If the arguments must be passed directly as actual arguments (not indirectly through a va_list pointer) to another function which is itself variadic (for which you do not have the option of creating an alternate, va_list-accepting version) no portable solution is possible. (The problem can be solved by resorting to machine-specific assembly language.
Related Questions
- How can I write a function which takes a variable number of arguments and passes them to some other function (which takes a variable number of arguments)?
- How can I write a function that takes a format string and a variable number of arguments, like printf, and passes them to printf to do most of the work?
- How can I write a function that takes a variable number of arguments?