mardi 25 mars 2014

Wrapping a variadic function topic




I'm trying to wrap the standard function fprintf() with a version called
qfprintf(). The following was done according to an on-line tutorial, but it
doesn't work (prints three random numbers, not 10 20 30).

Should it work? If not, how can it be done?

#include <stdio.h>
#include <stdarg.h>

int qfprintf(FILE* f, char* fmtstr, ...){
va_list args;
return vfprintf((FILE*)f, fmtstr, args);
}

int main(void) {

qfprintf(stdout,"%d %d %d\n", 10, 20, 30);

}

--
Bartc






Aucun commentaire:

Enregistrer un commentaire