首页 > 其他 > 详细

C log

时间:2020-02-28 19:05:59      阅读:66      评论:0      收藏:0      [点我收藏+]

 

 

#ifndef LOG2_H
#define LOG2_H
#include <stdio.h>

class log2
{
public:
    log2();
    static void d(char* s);
};

#endif // LOG2_H

 

#include "log2.h"
#include "time.h"
#include "windows.h"
log2::log2()
{

}

void log2::d(char *s)
{

   //fp = fopen("d:/tmp123/test.txt", "w+");
   FILE* pFile = fopen("logc.txt", "a");


//   time_t time_log = time(NULL);
//   struct tm* tm_log = localtime(&time_log);
//   fprintf(pFile, "%04d-%02d-%02d %02d:%02d:%02d ", tm_log->tm_year + 1900, tm_log->tm_mon + 1, tm_log->tm_mday,
//           tm_log->tm_hour, tm_log->tm_min, tm_log->tm_sec);


   SYSTEMTIME st ={0};
   GetLocalTime(&st);
   fprintf(pFile, "%04d-%02d-%02d %02d:%02d:%02d %03d ", st.wYear + 1900, st.wMonth + 1, st.wDay,
           st.wHour,st.wMinute, st.wSecond,st.wMilliseconds);

   fprintf(pFile,"%s\r\n",s);
   fflush(pFile);
   fclose(pFile);
}

 

C log

原文:https://www.cnblogs.com/ike_li/p/12378323.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!