码迷,mamicode.com
首页 > 其他好文 > 详细

C log

时间:2020-02-28 18:30:38      阅读:49      评论:0      收藏:0      [点我收藏+]

标签:nbsp   void   include   clu   close   txt   tmp   get   define   

 

 

#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

标签:nbsp   void   include   clu   close   txt   tmp   get   define   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!