Header file:
time.h
Synopsis:
char *asctime(const struct tm *tp);
Description:
It converts the time in the structure *tp to a string format.
asctime function C example:
#include<stdio.h>
#include<time.h>
int main() {
struct tm *tp;
time_t t;
char *str;
t = time(NULL);
tp = localtime(&t);
str = asctime(tp);
printf("Output:%s\n", str);
return 0;
}
#include<time.h>
int main() {
struct tm *tp;
time_t t;
char *str;
t = time(NULL);
tp = localtime(&t);
str = asctime(tp);
printf("Output:%s\n", str);
return 0;
}
Output:
jp@jp-VirtualBox:~/cpgms/time$ ./a.out
Output:Sat May 5 22:45:09 2012
Output:Sat May 5 22:45:09 2012
No comments:
Post a Comment