difftime返回值的单位是秒吗?
#include "stdlib.h"#include "time.h"int main(void){ time_t first, second; first = time(NULL); second = time(NULL); printf("%f", difftime(second, first)); return 0;}
#include <time.h>#include <stdio.h>int main(void){ time_t first, second; first = time(NULL); /* Gets system time */ sleep(2); /* Waits 2 secs */ second = time(NULL); /* Gets system time again */ printf("The difference is: %f seconds\n",difftime(second,first)); return 0;}[root@bogon temp]# ./t1The difference is: 2.000000 seconds测试证明,返回的是秒