关于time函数用法的小问题

来源:百度知道 编辑:UC知道 时间:2024/09/23 00:30:09
tt = time(0); << 26行
OsSleep(1000);
tt = time(0) - tt; <<28行
在这段函数中,26行的tt值是1970年1月1日0时0分0秒到此时的秒数吗?
time(0)和time(null)的区别是啥?

NULL的定义是:
#define NULL (void *)0

所以time(0)和time(NULL)是一样的

1.是的
2.没有区别

man 2 time的结果:
NAME
time - get time in seconds

SYNOPSIS
#include <time.h>

time_t time(time_t *t);

DESCRIPTION
time() returns the time since the Epoch (00:00:00 UTC, January 1, 1970), measured in seconds.

If t is non-NULL, the return value is also stored in the memory pointed to by t.

RETURN VALUE
On success, the value of time in seconds since the Epoch is returned. On error, ((time_t)-1) is returned, and
errno is set appropriately.