可用此函数实现日志处理结构形式如同(printf)

来源:互联网 发布:淘宝达人网址是多少 编辑:程序博客网 时间:2024/06/15 22:25

extern "C" void SaveMessageLog(LPCSTR szFormat, ...)
{
 CHAR tmp[100];
 va_list vl;
 ZeroMemory(tmp, 100);
 va_start(vl, szFormat);
 _vsnprintf(tmp, 99, szFormat, vl);
 va_end(vl);
 CFile file("\\RecvMsglog.txt", CFile::modeCreate | CFile::modeNoTruncate | CFile::modeWrite);
 file.SeekToEnd(); //移到行尾,下次记录换行
 file.Write(tmp, strlen(tmp));
 file.Close(); //MessageBox(NULL,tmp,tmp,MB_OK);
}

原创粉丝点击