I'm having troubles parsing a variable list of arguments...
Code:
#include <stdarg.h>
#include <stdio.h>
void debug_output(const char *s, ...){
va_list arglist;
//#ifdef _DEBUG
if(!s) return;
va_start(arglist, s);
fprintf(stderr,s,arglist);
va_end(arglist);
//#endif
}
int main(){
debug_output("Exp 0\n");
debug_output("Exp 1: %s\n","asd");
debug_output("Exp 2: %s %s\n","abc","def");
debug_output("Exp 3: %d\n",1);
debug_output("Exp 4: %d %d\n",6,7);
return 0;
}
And the output:
Code:
Exp 0
Exp 1: XPM
Exp 2: ,PM └↕
Exp 3: 1244976
Exp 4: 1244972 1245056
Clearly the list isn't being well formed... Any sugestions?