simple log function
Hi,i dont know if it should be here or it was answered before,google didnt really help.
I am trying to make a log(char *ctrlstr,...);
It should take the same parameters as ANSI C printf() or something similar
I see that way easier to debug,because i can know exactly where the process halted,or it'll help on error messages like "not enough memory","texture not found";
The problem is re-passing the arguments.
void log(char *ctrlstr,...)
{FILE *f;
f=fopen("error.log","a");
if(f==NULL) return;
fprintf(f,ctrlstrl, ??? );
fclose(f);
}
how to pass the arguments to fprintf ,something to replace the "???" place or analogous version.
I couldnt find it in books,and yes,i need to use printf, i dont want the c++ implementations with streams,<< or something.
Thanks in advance
From my code:
Where Log() just logs a normal const char* (You'd replace that with your call to fwrite() or whatever.
static void Format(const char* szFormat, ...){ char szBuff[1024]; va_list arg; va_start(arg, szFormat); _vsnprintf(szBuff, sizeof(szBuff), szFormat, arg); va_end(arg); Log(szBuff);}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement