宠物小精灵百变攻略:time()为什么要加参数NULL

来源:百度文库 编辑:中科新闻网 时间:2024/04/29 18:35:46
time()为什么要加参数NULL,或者限定time_t类型变量?如果换成time_t类型变量会怎么样?

谁帮解释一下MSDN的说明的最后一句:
The time function returns the number of seconds elapsed since midnight (00:00:00), January 1, 1970, coordinated universal time, according to the system clock. The return value is stored in the location given by timer. This parameter may be NULL, in which case the return value is not stored.

time()函数返回自1970年1月1日午夜0时0分0秒到现在所经过的秒数,这个返回值存储在本地(就是time_t类型的变量中),这个参数也可以为NULL,如果为NULL,那么time函数返回的值就不会被存储。