-
#include<stdio.h>
-
#include<time.h>
-
///可兼容打印tchar字符串 可用cw2a格式转换
-
#define TRACEOUT(p) \
-
{ \
-
time_t timeval; \
-
timeval=time(NULL); \
-
FILE *log; \
-
log = fopen("log.txt","a");\
-
fprintf(log,"%s -- %s\n",p,ctime(&timeval));\
-
fclose(log); \
-
}
-
-
int main()
-
{
-
TRACEOUT("hello");
-
return 0;
-
}
//////打印tchar会出错
//////cyrlog
{
CStdioFile filelog(_T("c:\\log10.txt"),CFile::modeCreate|CFile::modeNoTruncate|CFile::modeWrite);
filelog.SeekToEnd();//先定位到文件尾部
CString strTmp;
strTmp.Format(_T("hehe\r\n"));
filelog.WriteString(strTmp);
filelog.Close;
}
//////cyrlog
//////////////////////宽字节转换为多字节
///////////////1
char cName[1024]={0};
WideCharToMultiByte(CP_ACP,0,szMainIndex,-1,cName,sizeof(cName),NULL,NULL);
//////////////////2
char* pszLog=cw2a(szNum);