ctime函数--把日期和时间转换为字符串(打印时间时常用-LINUX系统)

论坛 期权论坛 脚本     
匿名技术用户   2020-12-29 08:23   11   0
函数: 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>头文件
分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:7942463
帖子:1588486
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP