zoukankan      html  css  js  c++  java
  • gettimeofday() 获取系统时间,精确到微秒 这个似乎只能在linux 下用,不能在windows 下用

    struct timeval{
        long int tv_sec; // 秒数  同time(NULL) 的返回值
        long int tv_usec; // 微秒数   10 的6次方
    };
    1 struct timezone{
    2     int tz_minuteswest;/*格林威治时间往西方的时差*/
    3     int tz_dsttime;/*DST 时间的修正方式*/
    4 };
     1 #include <stdio.h>
     2 #include <sys/time.h>
     3 
     4 int main()
     5 {
     6     struct timeval tv; 
     7     struct timezone tz; 
     8 
     9     int res = gettimeofday(&tv, &tz);
    10     printf("res = %d
    ", res);
    11     printf("tv.tv_sec = %ld, tv.tv_usec = %ld
    ", 
    12             tv.tv_sec, tv.tv_usec);
    13 
    14     return 0;
    15 }
  • 相关阅读:
    LeetCode OJ
    LeetCode OJ
    LeetCode OJ
    LeetCode OJ
    LeetCode OJ
    LeetCode OJ
    LeetCode OJ
    LeetCode OJ
    LeetCode OJ
    LeetCode OJ
  • 原文地址:https://www.cnblogs.com/suyunhong/p/4489100.html
Copyright © 2011-2022 走看看