time() function and random number generation

Often times, the time() function is called with parameter 0. I tried reading the documentation of the time() function, but I had trouble understanding it.

So it takes a pointer to a time_h object. What if the pointer is a null pointer? What is the time returned? What if it is NOT a null pointer, then what is the time returned?

This is the documentation for the ctime header:
http://www.cplusplus.com/reference/clibrary/ctime/
Last edited on
It returns the same thing regardless of its parameter, but if the parameter is a non-null pointer, the time_t object it points to is set to the return value.
In other words, these two lines are equivalent:
1
2
t=time(0);
time(&t);

Admittedly, that entry is not terribly well-written.
Last edited on
@helios,

I see, thanks!
Topic archived. No new replies allowed.