中文字幕 另类精品,亚洲欧美一区二区蜜桃,日本在线精品视频免费,孩交精品乱子片免费

<sup id="3hn2b"></sup>

    1. <sub id="3hn2b"><ol id="3hn2b"></ol></sub><legend id="3hn2b"></legend>

      1. <xmp id="3hn2b"></xmp>

      2. "); //-->

        博客專欄

        EEPW首頁 > 博客 > gettimeofday()函數(shù)來得到時間

        gettimeofday()函數(shù)來得到時間

        發(fā)布人:電子禪石 時間:2019-11-20 來源:工程師 發(fā)布文章

        gettimeofday()函數(shù)的使用方法:

        1.簡介:

        在C語言中可以使用函數(shù)gettimeofday()函數(shù)來得到時間。它的精度可以達到微妙

        2.函數(shù)原型:

        #include<sys/time.h>

        int gettimeofday(struct  timeval*tv,struct  timezone *tz )

        3.說明:

        gettimeofday()會把目前的時間用tv 結構體返回,當?shù)貢r區(qū)的信息則放到tz所指的結構中

        4.結構體:

        1>timeval

        struct  timeval{

           

               long  tv_sec;/*秒*/

               long  tv_usec;/*微妙*/

        };

        2>timezone 結構定義為:

        struct  timezone{

                int tz_minuteswest;/*和greenwich 時間差了多少分鐘*/

                int tz_dsttime;/*type of DST correction*/

        }

        3>在gettimeofday()函數(shù)中tv或者tz都可以為空。如果為空則就不返回其對應的結構體。

        4>函數(shù)執(zhí)行成功后返回0,失敗后返回-1,錯誤代碼存于errno中。

        5.程序實例:

        #include<stdio.h>
        #include<sys/time.h>

        #include<unistd.h>

         

        int main()

        {

                struct  timeval    tv;

                struct  timezone   tz;

                gettimeofday(&tv,&tz);

         

                printf(“tv_sec:%d\n”,tv.tv_sec);

                printf(“tv_usec:%d\n”,tv.tv_usec);

                printf(“tz_minuteswest:%d\n”,tz.tz_minuteswest);

                printf(“tz_dsttime:%d\n”,tz.tz_dsttime);

        }

        說明:在使用gettimeofday()函數(shù)時,第二個參數(shù)一般都為空,因為我們一般都只是為了獲得當前時間,而不用獲得timezone的數(shù)值


        *博客內(nèi)容為網(wǎng)友個人發(fā)布,僅代表博主個人觀點,如有侵權請聯(lián)系工作人員刪除。



        關鍵詞:

        相關推薦

        技術專區(qū)

        關閉