C语言里怎样获取系统时间?

0x1000 2008-11-19 12:46:39
尽量简单,谢谢!
...全文
76 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
lbh2001 2008-11-19
  • 打赏
  • 举报
回复
#include <time.h>
time_t time( time_t *time );



The function time() returns the current time, or -1 if there is an error. If the argument time is given, then the current time is stored in time.

太乙 2008-11-19
  • 打赏
  • 举报
回复
http://topic.csdn.net/u/20081021/20/c4a89853-ccbb-4081-8b2c-3e0ef81fc65b.html?seed=577567542
lala_benben 2008-11-19
  • 打赏
  • 举报
回复
time_t time;
time = time(NULL);
struct tm* ltm = localtime(&time);


wuyu637 2008-11-19
  • 打赏
  • 举报
回复
在Unix下可以用gettimeofday(). 原则上可准确到微秒。实际情况可能不是这样的。目前大多数系统是分时系统,不是实时系统。

在Unix/Win下可以用标准库中的time().这是将从1970年1月1日0点到当前的时间间隔(单位是秒)。或在Win32下用QueryPerformance等API。

69,373

社区成员

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

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