The method you are looking for is vfprintf
or possible vprintf
(unclear which by your question)
- http://www.cplusplus.com/reference/cstdio/vfprintf/
- http://www.cplusplus.com/reference/cstdio/vprintf/
This is essentially the implementation of printf
that allows a va_list
to be explicitly passed in as a parameter. So in your method you can create the va_list
for your method parameters and forward it onto vfprintf
void log(FILE* f, const char* format, ...) {
va_list args;
va_start (args, format);
vfprintf (f, format, args);
va_end (args);
}