新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

库函数调用之时间的显示、计算、应用

                                                            时间类型
UTC世界时间
日历时间
从1970年1月1日
#include
struct tm *gmtime(const time_t*timep)
功能;将日历时间转化格林威志时间;
struct tm{

创新互联建站专注于庆元企业网站建设,成都响应式网站建设,商城建设。庆元网站建设公司,为庆元等地区提供建站服务。全流程按需策划设计,专业设计,全程项目跟踪,创新互联建站专业和态度为您提供的服务

int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year; //tm_year +1900=哪一年
int tm_wday;
int tm_yday;
int tm_isdst;

}
#include
#include
int main(void){
struct tm *local;
time_t t;
t=time(NULL);
local=localtime(&t);
printf("local hour time:%d\n",loccal->tm_hour);
local=gmtime(&t);
printf("utc hour is :%d/n",local->tm_hour);return 0;

}

获取时间
int gettimeofday(struct timeval *tv,struct timezone tz*)
功能;获取从今日凌晨到现在的时差

struct timeval{


int tv_sec; //miao
int tv_usec;//wei miao


};

#include
#include
#include
#include

 

/************时间函数,延迟函数****************/
void function()
{
 unsigned int i,j;
 double y;
 for(i=0;i<1000;i++)
 for(j=0;j<1000;j++)
 j++;

}

/*******此函数可以计算出一个函数运行的时间********/
main()
{
struct timeval tpstart ,tpend;
float timesuel
gettimeofday(&tpstat,NULL);              // time of start
function();
gettimeofday(&tpend,NULL);              //count time end ;
/*count  time*/

timeuse=1000000*(tpend.tv_sec-tpstart.tv_set);
printf("used time ;\n",timeuse);
exit(0);
}


 


新闻标题:库函数调用之时间的显示、计算、应用
本文地址:http://www.wjwzjz.com/article/gppcge.html
在线咨询
服务热线
服务热线:028-86922220
TOP