Function name : time
Header file : <time.h>
Function prototype : long time(long *t);
Function : Get system time
Parameters : is the current time
Return value : Returns the current system time
Replenish :
(1) t1=time(NULL) or t1=time(0)
Pass a null pointer to the time() function and assign the time() return value to the variable t1
(2) time(&t2);
Pass the address of variable t2 as an actual parameter to the time() function, and the function automatically passes the result to t2 without the need for additional assignment statements.
Program example: Get the system time and output the result
#include<stdio.h>#include<time.h>intmain(void){time_tt;t=time(NULL);printf(ThenumberofsecondssinceJanuary1,1970is%ldn,t);return0;}
Running results:
ThenumberofsecondssinceJanuary1,1970is1592304422