Header file:
time.h
Synopsis:
time_t time(time_t *tp);
Description:
Returns current calendar time if tp is NULL or returns -1 on failure. If tp is not NULL, then the return value is assigned to *tp.
time function C example:
#include<stdio.h>
#include<time.h>
int main() {
time_t tp, ret;
printf("time(NULL):%ld\n", time(NULL));
sleep(5);
ret = time(&tp);
printf("Return value: %ld\ntp:%ld\n", ret, tp);
return 0;
}
#include<time.h>
int main() {
time_t tp, ret;
printf("time(NULL):%ld\n", time(NULL));
sleep(5);
ret = time(&tp);
printf("Return value: %ld\ntp:%ld\n", ret, tp);
return 0;
}
Output:
jp@jp-VirtualBox:~/cpgms/time$ ./a.out
time(NULL):1336234593
Return value: 1336234598
tp:1336234598
time(NULL):1336234593
Return value: 1336234598
tp:1336234598
No comments:
Post a Comment