Guardian C Library Calls Reference Manual
Reference to Library Calls
Guardian TNS C Library Calls Reference Manual—128833 3-23
ctime
timer
points to the calendar time.
Return Value
is a pointer to the string.
Usage Guidelines
•
The ctime function is equivalent to:
asctime(localtime(*timer));
•
Later calls to asctime and ctime overwrite the string. Refer to “asctime” on page 3-3
for more details.
Examples
1. This example converts the calendar time pointed to by &now to local time in the
form of a string.
#include <timeh>
#include <stdioh>
time_t now;
int main(void)
{
now = time(NULL);
printf("\n%s%s\n", "ctime(&now) = ", ctime(&now));
}
2. This example shows two alternate methods for converting the calendar time to local
time in the form of a string. Note that ctime(&now) and asctime(localtime(&now))
are equivalent function calls.
#include <timeh>
#include <stdioh>
time_t now;
int main(void)
{
now = time(NULL);
printf("\n%s%s\n%s%s\n",
" ctime(&now) = ", ctime(&now),
"asctime(localtime(&now)) = ", asctime(localtime(&now)));
}