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

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\t%s\n", tm.tm_mon + 1, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, msec.millitm, "test string");

 

相关文章:

  • 2021-09-03
  • 2021-11-19
  • 2021-08-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-26
  • 2022-02-06
猜你喜欢
  • 2021-07-24
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-04
  • 2022-12-23
相关资源
相似解决方案