zoukankan      html  css  js  c++  java
  • c++程序中写测试log到文件的简单实现

    1、int WriteToLog(char* str)
    {
    FILE* log;
    log = fopen("D:\\testlog.txt", "a+");
    if (log == NULL){
    //OutputDebugString("Log file open failed.");
    return -1;
    }
    fprintf(log, "%s\n", str);
    fclose(log);
    return 0;
    }

     2、带时间的实现

    1. void WriteLog(char * szLog)  
    2. {  
    3.                  SYSTEMTIME st;  
    4.                  GetLocalTime(&st);  
    5.                  FILE *fp;  
    6.                  fp=fopen("D:\\log.txt","at");  
    7.                  fprintf(fp,"MyLogInfo: %d:%d:%d:%d ",st.wHour,st.wMinute,st.wSecond,st.wMilliseconds);  
    8.                  fprintf(fp,szLog);  
    9.                  fclose(fp);  
    10.                  OutputDebugStringA(szLog);  
  • 相关阅读:
    JS 中 this 关键字详解
    Excel 文本函数
    Excel 日期和时间函数
    Excel引用和数学函数
    Excel-查找函数
    Excel-统计函数
    数据分析-业务知识
    Excel-逻辑函数
    Excel-基本操作
    电商数据分析总结
  • 原文地址:https://www.cnblogs.com/lidabo/p/2998357.html
Copyright © 2011-2022 走看看