<em id="0a85b"><option id="0a85b"></option></em>

<abbr id="0a85b"></abbr>

      <nobr id="0a85b"></nobr>
        <tr id="0a85b"></tr>
        9久久伊人精品综合,亚洲一区精品视频在线,成 人免费va视频,国产一区二区三区黄网,99国产精品永久免费视频,亚洲毛片多多影院,精品久久久无码人妻中文字幕,无码国产欧美一区二区三区不卡
        學(xué)習(xí)啦 > 學(xué)習(xí)英語(yǔ) > 專(zhuān)業(yè)英語(yǔ) > 計(jì)算機(jī)英語(yǔ) > c語(yǔ)言中time函數(shù)的用法

        c語(yǔ)言中time函數(shù)的用法

        時(shí)間: 長(zhǎng)思709 分享

        c語(yǔ)言中time函數(shù)的用法

          c語(yǔ)言中time函數(shù)的用法的用法你知道嗎?下面小編就跟你們?cè)敿?xì)介紹下c語(yǔ)言中time函數(shù)的用法的用法,希望對(duì)你們有用。

          c語(yǔ)言中time函數(shù)的用法的用法如下:

          頭文件time.h

          @函數(shù)名稱: localtime

          函數(shù)原型: struct tm *localtime(const time_t *timer)

          函數(shù)功能: 返回一個(gè)以tm結(jié)構(gòu)表達(dá)的機(jī)器時(shí)間信息

          函數(shù)返回: 以tm結(jié)構(gòu)表達(dá)的時(shí)間,結(jié)構(gòu)tm定義如下:

          [cpp] view plain copy

          01.struct tm{

          02. int tm_sec;

          03. int tm_min;

          04. int tm_hour;

          05. int tm_mday;

          06. int tm_mon;

          07. int tm_year;

          08. int tm_wday;

          09. int tm_yday;

          10. int tm_isdst;

          11. };

          參數(shù)說(shuō)明: timer-使用time()函數(shù)獲得的機(jī)器時(shí)間

          [cpp] view plain copy

          01.#include <time.h>

          02.#include <stdio.h>

          03.#include <dos.h>

          04.int main() {

          05. time_t timer;

          06. struct tm *tblock;

          07. timer=time(NULL);

          08. tblock=localtime(&timer);

          09. printf("Local time is: %s",asctime(tblock));

          10. return 0;

          11.}

          @函數(shù)名稱: asctime

          函數(shù)原型: char* asctime(struct tm * ptr)

          函數(shù)功能: 得到機(jī)器時(shí)間(日期時(shí)間轉(zhuǎn)換為ASCII碼)

          函數(shù)返回: 返回的時(shí)間字符串格式為:星期,月,日,小時(shí):分:秒,年

          參數(shù)說(shuō)明: 結(jié)構(gòu)指針ptr應(yīng)通過(guò)函數(shù)localtime()和gmtime()得到

          所屬文件: <time.h>

          [cpp] view plain copy

          01.#include <stdio.h>

          02.#include <string.h>

          03.#include <time.h>

          04. int main() {

          05. struct tm t;

          06. char str[80];

          07. t.tm_sec=1;

          08. t.tm_min=3;

          09. t.tm_hour=7;

          10. t.tm_mday=22;

          11. t.tm_mon=11;

          12. t.tm_year=56;

          13. t.tm_wday=4;

          14. t.tm_yday=0;

          15. t.tm_isdst=0;

          16. strcpy(str,asctime(&t));

          17. printf("%s",str);

          18. return 0;

          19.}

          @函數(shù)名稱: ctime

          函數(shù)原型: char *ctime(long time)

          函數(shù)功能: 得到日歷時(shí)間

          函數(shù)返回: 返回字符串格式:星期,月,日,小時(shí):分:秒,年

          參數(shù)說(shuō)明: time-該參數(shù)應(yīng)由函數(shù)time獲得

          所屬文件: <time.h>

          [cpp] view plain copy

          01.#include <stdio.h>

          02.#include <time.h>

          03.int main() {

          04. time_t t;

          05. time(&t);

          06. printf("Today's date and time: %s",ctime(&t));

          07. return 0;

          08.}

          @函數(shù)名稱: difftime

          函數(shù)原型: double difftime(time_t time2, time_t time1)

          函數(shù)功能: 得到兩次機(jī)器時(shí)間差,單位為秒

          函數(shù)返回: 時(shí)間差,單位為秒

          參數(shù)說(shuō)明: time1-機(jī)器時(shí)間一,time2-機(jī)器時(shí)間二.該參數(shù)應(yīng)使用time函數(shù)獲得

          所屬文件: <time.h>

          [cpp] view plain copy

          01.#include <time.h>

          02.#include <stdio.h>

          03.#include <dos.h>

          04.#include <conio.h>

          05.int main() {

          06. time_t first, second;

          07. clrscr();

          08. first=time(NULL);

          09. delay(2000);

          10. second=time(NULL);

          11. printf("The difference is: %f seconds",difftime(second,first));

          12. getch();

          13. return 0;

          14.}

          @函數(shù)名稱: gmtime

          函數(shù)原型: struct tm *gmtime(time_t *time)

          函數(shù)功能: 得到以結(jié)構(gòu)tm表示的時(shí)間信息

          函數(shù)返回: 以結(jié)構(gòu)tm表示的時(shí)間信息指針

          參數(shù)說(shuō)明: time-用函數(shù)time()得到的時(shí)間信息

          所屬文件: <time.h>

          [cpp] view plain copy

          01.#include <stdio.h>

          02.#include <stdlib.h>

          03.#include <time.h>

          04.#include <dos.h>

          05.char *tzstr="TZ=PST8PDT";

          06.int main() {

          07. time_t t;

          08. struct tm *gmt, *area;

          09. putenv(tzstr);

          10. tzset();

          11. t=time(NULL);

          12. area=localtime(&t);

          13. printf("Local time is:%s", asctime(area));

          14. gmt=gmtime(&t);

          15. printf("GMT is:%s", asctime(gmt));

          16. return 0;

          17.}

          @函數(shù)名稱: time

          函數(shù)原型: time_t time(time_t *timer)

          函數(shù)功能: 得到機(jī)器的日歷時(shí)間或者設(shè)置日歷時(shí)間

          函數(shù)返回: 機(jī)器日歷時(shí)間

          參數(shù)說(shuō)明: timer=NULL時(shí)得到機(jī)器日歷時(shí)間,timer=時(shí)間數(shù)值時(shí),用于設(shè)置日歷時(shí)間,time_t是一個(gè)long類(lèi)型

          所屬文件: <time.h>

          [cpp] view plain copy

          01.#include <time.h>

          02.#include <stdio.h>

          03.#include <dos.h>

          04.int main() {

          05. time_t t;

          06. t=time();

          07. printf("The number of seconds since January 1,1970 is %ld",t);

          08. return 0;

          09.}

          @函數(shù)名稱: tzset

          函數(shù)原型: void tzset(void)

          函數(shù)功能: UNIX兼容函數(shù),用于得到時(shí)區(qū),在DOS環(huán)境下無(wú)用途

          函數(shù)返回:

          參數(shù)說(shuō)明:

          所屬文件: <time.h>

          [cpp] view plain copy

          01.#include <time.h>

          02.#include <stdlib.h>

          03.#include <stdio.h>

          04.int main() {

          05. time_t td;

          06. putenv("TZ=PST8PDT");

          07. tzset();

          08. time(&td);

          09. printf("Current time=%s",asctime(localtime(&td)));

          10. return 0;

          11.}

        533435 主站蜘蛛池模板: 青青草欧美| 国产成人高清精品亚洲| 无码中文字幕热热久久| 人人妻人人狠人人爽| 久久精品久久电影免费理论片| 亚洲成在人线AV品善网好看| 亚洲另类无码一区二区三区| av在线 亚洲 天堂| 石原莉奈日韩一区二区三区 | 久久综合久中文字幕青草| 国产在线观看一区精品| 小嫩模无套内谢第一次| 亚洲AV秘 无码一区二区三区1| 国产自拍偷拍视频在线观看| 国产欧美另类精品久久久 | 久久经精品久久精品免费观看 | 日韩乱码人妻无码中文字幕视频| 四虎永久在线精品无码视频| 久久国产精品老人性| 亚洲人成网站18禁止无码| 风流老熟女一区二区三区| 亚洲精品国产免费av| 亚洲av永久无码天堂网| 国产免费午夜福利在线播放| 日韩毛片在线视频x| 午夜在线不卡| 亚洲午夜亚洲精品国产成人| 亚洲欧美日韩成人综合一区| 日本一区二区在线高清观看| 国产一区二区三区精美视频| 国产一区二区午夜福利久久| 亚洲国产另类久久久精品| 亚洲国产精品久久久久秋霞| 国产精品流白浆在线观看| 日日橹狠狠爱欧美视频| 99精品视频在线观看免费专区| 亚洲va久久久噜噜噜久久狠狠| 久久九九久精品国产| 成人无码潮喷在线观看| 日本精品一区二区在线看| 亚洲精品综合一区二区三区|