The C Programming Language - Pointers
This is a free tutorial about pointers from the book "The C Programming Language" by Heimo Gaicher
This is a free tutorial about pointers from the book "The C Programming Language" by Heimo Gaicher
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
For this we need the function time(), which is defined in the header file . This<br />
function returns the UTC time in seconds.<br />
Syntax:<br />
time_t time(time_t *second)<br />
/* example 137 - get UTC time in seconds */<br />
#include <br />
#include <br />
void getSecondsUTC(unsigned long *ptr_time) {<br />
// get the current number of secondsonds since 1970.01.01 00:00:00 UTC<br />
*ptr_time = time(NULL);<br />
}<br />
int main (void)<br />
{<br />
unsigned long seconds;<br />
getSecondsUTC(&seconds);<br />
// pass the address of seconds<br />
printf("Number of seconds since 1970.01.01: %ld\n", seconds);<br />
printf("Number of minutes since 1970.01.01: %ld\n", seconds/60);<br />
printf("Number of hours since 1970.01.01: %ld\n", seconds/3600);<br />
printf("Number of days since 1970.01.01: %ld\n", seconds/(3600*24));<br />
}<br />
return 0;<br />
Number of seconds since 1970.01.01: 1674053452<br />
Number of minutes since 1970.01.01: 27900890<br />
Number of hours since 1970.01.01: 465014<br />
Number of days since 1970.01.01: 19375<br />
<strong>The</strong> C <strong>Programming</strong> <strong>Language</strong> by Heimo Gaicher – Chapter <strong>Pointers</strong> 20