本站首页    管理页面    写新日志    退出


«July 2025»
12345
6789101112
13141516171819
20212223242526
2728293031


公告

谦卑,荣誉,牺牲,英勇,怜悯,诚实,精神,公正。


我的分类(专题)

日志更新

最新评论

留言板

链接

 

 


Blog信息
blog名称:
日志总数:183
评论数量:698
留言数量:7
访问次数:3016619
建立时间:2005年12月29日




[编程学习]About gettime() && getsystime()
读书笔记

newqiang 发表于 2006/1/11 15:25:13

1. #include <stdio.h>#include <time.h> void main( void ){/*struct tm {int tm_sec;// seconds after the minute - [0,59]int tm_min;/* minutes after the hour - [0,59]int tm_hour;/* hours since midnight - [0,23]int tm_mday;/* day of the month - [1,31]int tm_mon;/* months since January - [0,11]int tm_year;/* years since 1900int tm_wday;/* days since Sunday - [0,6]int tm_yday;/* days since January 1 - [0,365]int tm_isdst;/* daylight savings time flag}; */ tm systime; _getsystime(&systime); printf( "Current OS date and time: %s", asctime( &systime ) );  tm timetobeset; // below is the value to be set for the system time ( I set it to 2004/12/01 0:00:00 ) : timetobeset.tm_sec=0;// seconds after the minute - [0,59] timetobeset.tm_min=0;// minutes after the hour - [0,59] timetobeset.tm_hour=0;// hours since midnight - [0,23] timetobeset.tm_mday=1;// day of the month - [1,31] timetobeset.tm_mon=11;// months since January - [0,11] timetobeset.tm_year=104;// years since 1900 timetobeset.tm_wday=3;// days since Sunday - [0,6] timetobeset.tm_yday=335;// days since January 1 - [0,365] timetobeset.tm_isdst=0;// daylight savings time flag //_setsystime(&timetobeset, 0); printf( "Current OS date and time is set to be : %s", asctime( &timetobeset ) );}  2. main(){long i;struct time t1,t2;double dt1,dt2;gettime(&t1);for(i=0;i<500000;i++){ delay(1000);}gettime(&t2);dt1=(double)t1.ti_hour*3600+t1.ti_min*60+t1.ti_sec;dt2=(double)t2.ti_hour*3600+t2.ti_min*60+t2.ti_sec; printf("\ndifftime:%lf\n",dt2-dt1);getch();}


阅读全文(7617) | 回复(0) | 编辑 | 精华
 



发表评论:
昵称:
密码:
主页:
标题:
验证码:  (不区分大小写,请仔细填写,输错需重写评论内容!)



站点首页 | 联系我们 | 博客注册 | 博客登陆

Sponsored By W3CHINA
W3CHINA Blog 0.8 Processed in 0.078 second(s), page refreshed 144749997 times.
《全国人大常委会关于维护互联网安全的决定》  《计算机信息网络国际联网安全保护管理办法》
苏ICP备05006046号