I’m trying to use vfprintf in the following way
vfprintf(fp, buffer, arg);
fp log file that I create using the date and time of the run, a buffer and the rest of the args
fp = fopen(filename, "a");
va_start(arg, message);
vprintf(message, arg); // print stdout
vfprintf(fp, buffer, arg); // print to file
va_end(arg);
fclose(fp);
it works perfectly with numbers and it dies horribly with the error: vfprintf source not found at ….
Does anyone have any idea what I’m doing wrong by any chance?
You are probably using a 64-bit architecture where variable length
argcan only be passed over once. To make more passes copyargusingva_copy():From
man va_arg: