C语言怎么把系统时间输出出来?

 我来答
匿名用户
2013-09-02
展开全部
#include <stdio.h>
#include <time.h>
void main()
{
time_t timep;
time (&timep);
printf("%s",ctime(&timep));
}
运行结果:
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
a1012144015
2015-05-16 · TA获得超过6415个赞
知道大有可为答主
回答量:9038
采纳率:40%
帮助的人:1301万
展开全部
代码如下:(还有其他时间函数类型,有需要再问)#include"stdio.h"
#include"time.h"
int main()
{
time_t t;
time(&t);
printf("%s",ctime(&t));
return 0;
}
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
百度网友18222f6
2015-07-05 · TA获得超过697个赞
知道小有建树答主
回答量:1381
采纳率:50%
帮助的人:401万
展开全部
使用time函数。
time
Defined in header <time.h>
time_t time( time_t *time );

Returns the current calendar time encoded as a time_t object.

Parameters
time - pointer to a time_t object to store the time in or NULL

Return value
Current calendar time encoded as time_t object on success, (time_t)(-1) on error. If the argument is not NULL, the return value is equal to the value stored in the object pointed to by the argument.
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
匿名用户
2013-09-02
展开全部
用time函数,不过这个不准
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
匿名用户
2013-09-02
展开全部
代码如下:【还有其他时间函数类型,在后面补充】#include"stdio.h"
#include"time.h"
int main()
{
time_t t;
time(&t);
printf("%s",ctime(&t));
return 0;
} 补充部分:【以下主要用于对所需时间变量的输出】#include <dos.h>
#include <stdio.h>
int main(void)
{
struct date d;
struct time t;
getdate(&d);
gettime(&t);
printf("The current year is: %d\n",d.da_year); /*此变量单输出年*/
printf("The current month is: %d\n",d.da_mon); /*此变量单输出月*/
printf("The current day is: %d\n",d.da_day); /*此变量单输出日*/
printf("The current time is: %2d:%02d:%02d.%02d\n",t.ti_hour, t.ti_min, t.ti_sec, t.ti_hund); /*时间变量分别输出是时、分、秒及秒以下的单位*/ return 0;
}效果如下 希望回答对你有帮助!
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
收起 1条折叠回答
收起 更多回答(3)
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式