有两个时间,一个时间A,一个时间B,单纯用秒数进行会出现不确定A快或者B快的现象,so ..产用difftime函数并对其返回值去绝对值即可得到AB之间的差
#include
#include
#include
int main(void)
{
time_t first, second;
first = time(NULL); /* Gets system
time */
sleep(2); /* Waits 2 secs */
second = time(NULL); /* Gets system time*/
printf("The difference is: %d seconds\n",(int)abs(difftime(first, second)));
getchar();
return 0;
}
阅读(3319) | 评论(0) | 转发(1) |