void WriteLog(char * szLog, int nError)
{
SYSTEMTIME st;
GetLocalTime(&st);
FILE *fp;
fp = fopen("D:\\log.txt", "at");
fprintf(fp, "MyLogInfo: %d:%d:%d:%d, The Err Num is %d ", st.wHour, st.wMinute, st.wSecond, st.wMilliseconds, nError);
fprintf(fp, szLog);
fclose(fp);
OutputDebugStringA(szLog);
}
调用方式:
WriteLog("************Test*************\n", nError);