函数: ctime
功 能: 把
日期和时间转换为字符串
用 法: char *ctime(const time_t *time);
程序例:
1
2
3
4
5
6
7
8
9
|
#include<cstdio>
#include<ctime>
int
main(
void
)
{
time_t
t;
t=
time
(&t);
printf
(
"Today'sdateandtime:%s\n"
,
ctime
(&t));
return
0;
}
|
注:若在linux下使用本函数,需要include <time.h>头文件