06.08.2013 Views

pSOSystem System Calls - Read

pSOSystem System Calls - Read

pSOSystem System Calls - Read

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

mktime pREPC+ <strong>System</strong> <strong>Calls</strong><br />

Return Value<br />

Error Codes<br />

Example<br />

The mktime() function returns the specified calendar time encoded as a value of<br />

type time_t. If the calendar time cannot be represented, the function returns the<br />

value (time_t) -1.<br />

None.<br />

What day of the week is July 4, 2001?<br />

#include <br />

#include <br />

static const char *const wday[] = {<br />

“Sunday”, “Monday”, “Tuesday”, “Wednesday”,<br />

“Thursday”, “Friday”, “Saturday”, “-unknown-”<br />

};<br />

struct tm time_str;<br />

/* ... */<br />

time_str.tm_year = 2001 - 1900;<br />

time_str.tm_mon = 7 - 1;<br />

time_str.tm_mday = 4;<br />

time_str.tm_hour = 0;<br />

time_str.tm_min = 0;<br />

time_str.tm_sec = 1;<br />

time_str.tm_isdst = -1;<br />

if (mktime(&time_str) == -1)<br />

time_str.tm_wday = 7;<br />

printf(“%s\n”, wday[time_str.tm_wday]);<br />

3-112 <strong>pSO<strong>System</strong></strong> <strong>System</strong> <strong>Calls</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!