奶头挺立呻吟高潮av全片,成人试看120秒体验区,性欧美极品v,A片高潮抽搐揉捏奶头视频

C語言

c語言中time函數的用法

時間:2024-08-27 16:01:11 C語言 我要投稿
  • 相關推薦

c語言中time函數的用法

  c語言中time函數的用法的用法你知道嗎?下面應屆畢業生小編就跟你們詳細介紹下c語言中time函數的用法的用法,希望對你們有用。

  c語言中time函數的用法的用法如下:

  頭文件time.h

  @函數名稱: localtime

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

  函數功能: 返回一個以tm結構表達的機器時間信息

  函數返回: 以tm結構表達的時間,結構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. };

  參數說明: timer-使用time()函數獲得的機器時間

  [cpp] view plain copy

  01.#include

  02.#include

  03.#include

  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.}

  @函數名稱: asctime

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

  函數功能: 得到機器時間(日期時間轉換為ASCII碼)

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

  參數說明: 結構指針ptr應通過函數localtime()和gmtime()得到

  所屬文件:

  [cpp] view plain copy

  01.#include

  02.#include

  03.#include

  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.}

  @函數名稱: ctime

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

  函數功能: 得到日歷時間

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

  參數說明: time-該參數應由函數time獲得

  所屬文件:

  [cpp] view plain copy

  01.#include

  02.#include

  03.int main() {

  04. time_t t;

  05. time(&t);

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

  07. return 0;

  08.}

  @函數名稱: difftime

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

  函數功能: 得到兩次機器時間差,單位為秒

  函數返回: 時間差,單位為秒

  參數說明: time1-機器時間一,time2-機器時間二.該參數應使用time函數獲得

  所屬文件:

  [cpp] view plain copy

  01.#include

  02.#include

  03.#include

  04.#include

  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.}

  @函數名稱: gmtime

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

  函數功能: 得到以結構tm表示的時間信息

  函數返回: 以結構tm表示的時間信息指針

  參數說明: time-用函數time()得到的時間信息

  所屬文件:

  [cpp] view plain copy

  01.#include

  02.#include

  03.#include

  04.#include

  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.}

  @函數名稱: time

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

  函數功能: 得到機器的日歷時間或者設置日歷時間

  函數返回: 機器日歷時間

  參數說明: timer=NULL時得到機器日歷時間,timer=時間數值時,用于設置日歷時間,time_t是一個long類型

  所屬文件:

  [cpp] view plain copy

  01.#include

  02.#include

  03.#include

  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.}

  @函數名稱: tzset

  函數原型: void tzset(void)

  函數功能: UNIX兼容函數,用于得到時區,在DOS環境下無用途

  函數返回:

  參數說明:

  所屬文件:

  [cpp] view plain copy

  01.#include

  02.#include

  03.#include

  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.}


【c語言中time函數的用法】相關文章:

C語言中strpbr()函數的用法03-19

C語言中isalnum()函數和isalpha()函數的對比04-01

C語言中函數的區分有哪些04-27

C語言中friend友元函數詳細解析04-01

C語言中返回字符串函數的實現方法03-19

C語言設置和取得socket狀態的相關函數用法介紹04-01

php語言中session用法12-03

html語言中URL的用法11-25

C++調用C函數的方法11-15

主站蜘蛛池模板: 阿勒泰市| 谢通门县| 汉寿县| 伽师县| 新兴县| 阿瓦提县| 塔河县| 张家界市| 社会| 孙吴县| 钦州市| 金沙县| 融水| 阳高县| 瓦房店市| 枣庄市| 始兴县| 临高县| 梁山县| 富裕县| 象山县| 海城市| 唐山市| 天气| 博乐市| 青河县| 景洪市| 大渡口区| 鄂托克前旗| 温泉县| 南宁市| 舟山市| 孝义市| 盐池县| 贺州市| 龙海市| 兴城市| 阿勒泰市| 十堰市| 临江市| 苍南县|