Pass varargs to printf [duplicate]
This question already has answers here : How to pass variable number of arguments to printf/sprintf (7 answers) I'd like to have a helper function log that essentially does the following: log(file, "array has %d elements\n", 10); // writes "2014-02-03 16:33:00 - array has 10 elements" to &file I have the time portion down, and I have the file writing portion down. However, the problem is the method signature itself for log — what should I put? This says that the printf declaration ends with the ... keyword, but how can I use this in my function? void log(FILE *f, const char * format, ...) //