double difftime(time_t time1, time_t time0);
The
difftime()
function returns the number of seconds elapsed between timetime1
and timetime0
, represented as adouble
.
既然“秒数”不需要 float ,为什么这个函数返回一个double
?
最佳答案
这documentation在这一点上更清楚:
On POSIX systems, time_t is measured in seconds, and difftime is equivalent to arithmetic subtraction, but C and C++ allow fractional units for time_t.
虽然POSIX requires time_t
to be an integer type ,对于非 POSIX 系统,这可能会返回小数秒。
关于c - 为什么 difftime() 会返回一个 double 值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34457931/