逝水流年

This is a blog to record my life, my work, my feeling …

分享一个日志函数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <stdio.h>;
#include <stdarg.h>;
void logTest(const char* content, ...)
{
    FILE* logfile = fopen("log.txt", "a");
    if(logfile)
    {
        fprintf(logfile, "########## NEW LOG ########\n");
        va_list arg;
        va_start(arg, content);
        vfprintf(logfile, content, arg);
        va_end(arg);
        int status = fflush(logfile);
        fclose(logfile);
    }
}

Comments