也许太简单了,可是我真的不知道!

RunningPuma 2001-05-30 10:58:00
请问在C/C++中如何获取系统的当前时间?
...全文
64 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
glhorse 2001-05-30
  • 打赏
  • 举报
回复
学一门语言,很重要的一点是会使用帮助!
ed9er 2001-05-30
  • 打赏
  • 举报
回复
标准c的话应该是time(time_t *)
而且没有到MSEC精度的函数
sundayboys 2001-05-30
  • 打赏
  • 举报
回复
#include <time.h>
#include <stdio.h>
#include <dos.h>

int main(void)
{
time_t timer;
struct tm *tblock;

/* gets time of day */
timer = time(NULL);

/* converts date/time to a structure */
tblock = localtime(&timer);

printf("Local time is: %s", asctime(tblock));

return 0;
}
tansoul 2001-05-30
  • 打赏
  • 举报
回复
在c中,你可以查一下库函数,我记得有这样的一个函数。
sundayboys 2001-05-30
  • 打赏
  • 举报
回复
now
tianye606 2001-05-30
  • 打赏
  • 举报
回复
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <conio.h>
void main( void )
{
struct tm *newtime;
char am_pm[] = "AM";
time_t long_time;

time(&long_time ); /* Get time as long integer. */
newtime = localtime( &long_time ); /* Convert to local time. */
printf("公元%d年%d月%d日 %d点%d分%d秒\n",newtime->tm_year,newtime->tm_mon
,newtime->tm_mday,newtime->tm_hour,newtime->tm_min,newtime->tm_sec);
_getch();
}

69,371

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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