当前时间 [英] current time

查看:55
本文介绍了当前时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我需要打印当前时间。


我找到了一个如下所示的例子:

长* mytime;

时间(mytime);

printf(" time:%s",ascitime(mytime);


但是这不起作用并打印出一些丑陋的数字。


这是如何正确完成的?

解决方案

Tim Quon写道:

我需要打印当前时间。

我找到了一个如下所示的例子:
long * mytime;
time(mytime);
printf(" time:%s",ascitime(mytime);




这3行中至少有6个错误!


time_t mytime = time(0);

printf(" time:%s \ n", asctime(localtime(& mytime)));


Jirka


2003年9月15日星期一13 :04:40 + 0200,Jirka Klaue

< jk **** @ ee.tu-berlin.de> wr ote:

Tim Quon写道:

我需要打印当前时间。

我找到了一个这样做的例子如下:
long * mytime;
time(mytime);
printf(" time:%s",ascitime(mytime);


这3行中至少有6个错误!

time_t mytime = time(0);
printf(" time:%s \ n",asctime(localtime(& mytime) ));;

Jirka




非常感谢。

永远不要相信来自网络的例子:'' )


Tim Quon< ti *** @ freesurf.ch>写道:

我找到了一个如下所示的例子:
long * mytime;
time(mytime);
printf("时间:%s",ascitime(mytime);

但这不起作用并打印出一些丑陋的数字。

这是如何正确完成的?




没有kiddin''。什么是time()的原型?什么是asctime()?(注意,

ascitime( )不存在......)特别是,这些函数需要什么样的参数?


Richard


Hi

I need to print the current time.

I found an example where this is done as followed:
long *mytime;
time(mytime);
printf("time: %s", ascitime(mytime);

But this doesn''t work and prints some ugly numbers.

How is this done correctly?

解决方案

Tim Quon wrote:

I need to print the current time.

I found an example where this is done as followed:
long *mytime;
time(mytime);
printf("time: %s", ascitime(mytime);



At least 6 errors in these 3 lines!

time_t mytime = time(0);
printf("time: %s\n", asctime(localtime(&mytime)));

Jirka


On Mon, 15 Sep 2003 13:04:40 +0200, Jirka Klaue
<jk****@ee.tu-berlin.de> wrote:

Tim Quon wrote:

I need to print the current time.

I found an example where this is done as followed:
long *mytime;
time(mytime);
printf("time: %s", ascitime(mytime);



At least 6 errors in these 3 lines!

time_t mytime = time(0);
printf("time: %s\n", asctime(localtime(&mytime)));

Jirka



Thanks a lot.
Never trust examples from the web :'')


Tim Quon <ti***@freesurf.ch> wrote:

I found an example where this is done as followed:
long *mytime;
time(mytime);
printf("time: %s", ascitime(mytime);

But this doesn''t work and prints some ugly numbers.

How is this done correctly?



No kiddin''. What is time()''s prototype? What is asctime()''s? (And note,
ascitime() doesn''t exist...) In particular, what kind of parameters do
these functions take?

Richard


这篇关于当前时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆