时间和日期函数
clock测定运行时间函数
#include"stdio.h" #include"time.h" #include"dos.h" #include "Windows.h" int main(void) { clock_t start,end; start=clock(); Sleep(1045); //delay(); end=clock(); printf("时间是:%-.3f秒\n",(double)(end-start)/CLK_TCK); return 0; }
difftime计算时间差函数
#include"time.h" #include"stdio.h" #include"dos.h" #include"conio.h" #include"Windows.h" void main() { time_t first,second; //clrscr(); first=time(NULL); Sleep(2000); second=time(NULL); printf("%f 秒\n",difftime(second,first)); }
time获取系统时间函数
#include"time.h" #include"stdio.h" void main() { time_t t; t=time(&t); printf("从1970年1月1日起到现在经过了%ld秒\n",t); printf("现在日期:%s\n",ctime(&t)); }
本文出自 “阿凡达” 博客,请务必保留此出处http://shamrock.blog.51cto.com/2079212/735850
积跬步以致千里,积小流以成江海。
2016年5月之前的博文发布于51cto,链接地址:shamrock.blog.51cto.com
2016年5月之后博文发布与cnblogs上。
Github地址 https://github.com/umgsai
Keep moving~!!!
2016年5月之前的博文发布于51cto,链接地址:shamrock.blog.51cto.com
2016年5月之后博文发布与cnblogs上。
Github地址 https://github.com/umgsai
Keep moving~!!!




浙公网安备 33010602011771号