Hi,
I want to combine DebugPrintf and fprintf into one function, say LogPrintf. The idea is that everywhere in my code that I use a DebugPrintf I could also be fprintf'ing to a log file.
Suppose my code says this:
int i = 0;
DebugPrintf("%s%d\n", "Hello world. Counter = ", i);
Instead I want to have it say:
int i = 0;
LogPrintf("%s%d\n", "Hello world. Counter = ", i);
The interface to LogPrintf would be exactly like the interface to DebugPrintf:
int LogPrintf (const char formatString[], ...);
Then within LogPrintf, and assuming I've already opened the log file to use for fprintf, I would put:
DebugPrintf(input formatting string, input arguments list);
fprintf(already opened log file pointer, input formatting string, input arguments list);
My problem is with the varargin (...) in the argument lists of DebugPrintf and fprintf. How do I pass the variable-length argument list as a parameter into the DebugPrintf and fprintf calls within LogPrintf ?
Any ideas?
Thanks!