I learning about some basic C functions and have encountered time(NULL)
in some manuals.
What exactly does this mean?
int main (void)
{
//print time in seconds from 1 Jan 1970 using c
float n = time(NULL);
printf("%.2f\n" , n);
}
this prints 1481986944.00 (at this moment).
You can pass in a pointer to a time_t
object that time will fill up with the current time (and the return value is the same one that you pointed to). If you pass in NULL
, it just ignores it and merely returns a new time_t
object that represents the current time.
Nb:time(&timer);
is equivalent to timer = time(NULL);