How to use the time () function in linux
This article mainly introduces how to use the time () function in linux. It is very detailed and has a certain reference value. Friends who are interested must finish it!
The time () function gets the current time
1 SYNOPSIS 2 # include 3 4 time_t time (time_t * t); 5 6 DESCRIPTION 7 time () returns the time as the number of seconds since the Epoch, 1970-01-01 00:00:00 + 0000 (UTC). 8 / / this function returns the number of seconds that have elapsed since 00:00:00 of UTC time on January 1, 1970. If t is not a null pointer, this function also stores the return value to the memory referred to by the t pointer. 9 RETURN VALUE 10 On success, the value of time in seconds since the Epoch is returned. On error, (time_t)-1) is returned, and errno is 11 set appropriately. 12 ERRORS 13 EFAULT t points outside your accessible address space. 14 / / the number of seconds returned for success, and the error returns (time_t)-1). The cause of the error is stored in errno eg:
1 # include 2 # include 3 # include 4 5 int main () 6 {7 time_t seconds; 8 9 seconds = time ((time_t *) NULL); 10 printf ("% d\ n", seconds); 11 12 return 0; 13} these are all the contents of the article "how to use the time () function in linux". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!