打印日志的时候显示毫秒

打印日志的时候需要细化到毫秒级别

time_t t = time(NULL);
    struct tm tm;
#if defined(_WIN32)
    localtime_s(&tm, &t);
#else
    tm = *localtime(&t);
#endif
    struct timeb msec;
    ftime(&msec);
    printf("%.2d/%.2d %.2d:%.2d:%.2d.%03d	%s
", tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, msec.millitm, "test string");
原文地址:https://www.cnblogs.com/yuandaozhe/p/11719620.html