Header file:
time.h
Synopsis:
char *ctime(const time_t *tp);
Description:
It coverts calendar time *tp to local time and returns the time in string format.
ctime function C example:
#include<stdio.h>
#include<time.h>
int main() {
time_t tp;
char *str;
tp = time(NULL);
str = ctime(&tp);
printf("%s\n", str);
return 0;
}
#include<time.h>
int main() {
time_t tp;
char *str;
tp = time(NULL);
str = ctime(&tp);
printf("%s\n", str);
return 0;
}
Output:
jp@jp-VirtualBox:~/cpgms/time$ ./a.out
Sat May 5 23:42:02 2012
Sat May 5 23:42:02 2012
No comments:
Post a Comment