在编译中自动生成时间戳?

hmn 2003-12-18 01:56:56
我想在程序的about 中自动加上编译的时间。如 日期,时间,请问什么技术可以实现?
...全文
252 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
hmn 2003-12-18
  • 打赏
  • 举报
回复
thanks a lot . I got it.
fierygnu 2003-12-18
  • 打赏
  • 举报
回复
printf("%s\t%s\n", __DATE__, __TIME__);
就是两个字符串。
hmn 2003-12-18
  • 打赏
  • 举报
回复
怎么写?多谢
fierygnu 2003-12-18
  • 打赏
  • 举报
回复
?gcc支持。
hmn 2003-12-18
  • 打赏
  • 举报
回复
I am sorry that it seems no such micro defined in linux and unix.
hanyixin 2003-12-18
  • 打赏
  • 举报
回复

有标准的宏可以完成这个任务
fierygnu 2003-12-18
  • 打赏
  • 举报
回复
__DATE__和__TIME__,与__FILE__、__LINE__一样使用。
__DATE__

The current date, a string literal. The form is

Apr 21 1990

where the month name is as defined in the library function asctime and the first digit of the date is a space if the date is less than 10.
__TIME__
The time of the translation; again a string literal in the form produced by asctime, which has the form "hh:mm:ss".
hmn 2003-12-18
  • 打赏
  • 举报
回复
我知道自己加起来不难,可是我还是想知道有没有实现的可能性。我见过BCB 的源码可以实现。但是忘了怎样做了,难道这样的菜问题也能难了大家?
erlengzi2003 2003-12-18
  • 打赏
  • 举报
回复
编译器只完成编译程序的工作,并不会得出运行结果,要得到系统的时间,必须要在运行时利用MFC相应类的方法才能够得到。其实没有必要自动添加,手工添加也不费事。

65,206

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧