如何获取系统当前时间?

DD88 2002-10-27 08:43:05
C++中如何实现?
...全文
132 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
WaterWalker 2002-10-28
  • 打赏
  • 举报
回复
#include <time.h>
#include <stdio.h>
void main()
{ char tmpbuf[128];
_strtime( tmpbuf );
printf( "OS time: %s\n", tmpbuf );
}
anchivehw 2002-10-27
  • 打赏
  • 举报
回复
和操作系统相关,以及CPU的设计类型,一定是DOS吗
srm2000 2002-10-27
  • 打赏
  • 举报
回复
gettime, settime

See also Examples Portability
Header File

dos.h

Category

Time and Date Routines

Syntax

#include <dos.h>
void gettime(struct time *timep);
void settime(struct time *timep);

Description

Gets and sets the system time.

gettime fills in the time structure pointed to by timep with the system's current time.

settime sets the system time to the values in the time structure pointed to by timep.

The time structure is defined as follows:

struct time {
unsigned char ti_min; /* minutes */
unsigned char ti_hour; /* hours */
unsigned char ti_hund; /* hundredths of seconds */
unsigned char ti_sec; /* seconds */
};

Return Value

None.
ckacka 2002-10-27
  • 打赏
  • 举报
回复
void ftime(struct timeb* timeptr)

in time.h file

69,371

社区成员

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

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