void Debug(char *text,...)
{
static DWORD num=0;
char buf[1024];
FILE *fp=NULL;
va_list ap;
va_start(ap,text);
vsprintf(buf,text,ap);
va_end(ap);
if(num == 0)
{
fp=fopen("文件名.log","w");
}
else
{
fp=fopen("文件名.log","a");
}
if(fp == NULL)
return ;
num++;
SYSTEMTIME time;
GetLocalTime(&time);
fprintf(fp, "%d:%s - %d/%d/%d %d:%d:%d \n", num, buf, time.wYear, time.wMonth, time.wDay, time.wHour, time.wMinute, time.wSecond);
fclose(fp);
}
LONGLONG lTest=123456;
调用方法:Debug("测试:%I64d",lTest);
实现的效果:测试:123456