C语言,关于time.h,int getSystemTime() { time_t timer; time(&timer); tm* t_tm = localtime(&timer); printf("today is %4d %02d %02d %02d %02d %02d\n",t_tm->tm_year+1900,t_tm->tm_mon+1,t_tm->tm_mday,t_tm->tm_hour,t_tm->tm_min,t_tm->tm_sec); return 0;

来源:学生作业帮助网 编辑:作业帮 时间:2024/11/26 15:49:54
C语言,关于time.h,int getSystemTime() { time_t timer; time(&timer); tm* t_tm = localtime(&timer); printf(tm_year+1900,t_tm->tm_mon+1,t_tm->tm_mday,t_tm->tm_hour,t_tm->tm_min,t_tm->tm_sec); return 0;" />
xT[OA+k/mLЗJD.Y4ƘU.DEAb[/krb>zf"o}˜97/+*y}뗄)a.$y|& (iL #L`b|6(b/}/ o'ޡ]O6ը󌋃wCC-:D ْbo !"zY/ ܟEGꙦL1Ϸd4V'-9w=A,V%..͊&n[dꡱh,eȻp \$~Ku< s[#W'V4eb5JX:b oJkITTȦFH,-ZƵ7!{pC29aT$f 7npZXIlt:`-Lqԩ(uzFL N\%^>3NO!dHbq. u+PT1m53_p5V|(A6v3R{Q;DdCWЩ)"j MAIٺ^=g@PSm|H*glBp@="JO@j8Si2ԌUqPa?oe50+O(iHj4=#

C语言,关于time.h,int getSystemTime() { time_t timer; time(&timer); tm* t_tm = localtime(&timer); printf("today is %4d %02d %02d %02d %02d %02d\n",t_tm->tm_year+1900,t_tm->tm_mon+1,t_tm->tm_mday,t_tm->tm_hour,t_tm->tm_min,t_tm->tm_sec); return 0;
C语言,关于time.h,
int getSystemTime()
{
time_t timer;
time(&timer);
tm* t_tm = localtime(&timer);
printf("today is %4d %02d %02d %02d %02d %02d\n",t_tm->tm_year+1900,
t_tm->tm_mon+1,t_tm->tm_mday,t_tm->tm_hour,t_tm->tm_min,t_tm->tm_sec);
return 0;
}
里面这些代码的意思实在是不懂,能不能帮我注释一下!
实在是麻烦大家了!
本人新手!
望见谅!

C语言,关于time.h,int getSystemTime() { time_t timer; time(&timer); tm* t_tm = localtime(&timer); printf("today is %4d %02d %02d %02d %02d %02d\n",t_tm->tm_year+1900,t_tm->tm_mon+1,t_tm->tm_mday,t_tm->tm_hour,t_tm->tm_min,t_tm->tm_sec); return 0;
首先你得了解time是一个结构体:
struct tm{
int tm_sec;//秒;
int tm_min;//分;
int tm_hour;//时;
int tm_mday;//日;
int tm_mom;//月;
int tm_year;//年;
int tm_wday;//星期;
int tm_yday;//一年中的第几天;
int tm_isdst;//是否为夏时制;
};
timer_t timer; time_t 其实就是long int timer.
time(&timer); time函数原型是time_t time(time_t *tp);提取当前的时间(以秒的形式,不懂搜百科)所以这句执行后等于是往timer变量里塞进了数据,是多少多少秒.
tm* t_tm=localtime(&timer);localtime()函数功能是将tp地址单元中的时间转换为日期时间结构的当地时间.就是,你把timer长整型转换为了日期时间结构了.就是类似于把3661秒转化为1(小时)1(分钟)1(秒钟)把这三个’1‘分别赋给了 tm_hour,tm_min和tm_sec;
最后就是打印了.