代码如下:【还有其他时间函数类型,在后面补充】#include"stdio.h"
#include"time.h"
int main()
{
time_t t;
time(&t);
printf("%s",ctime(&t));
return 0;
} 补充部分:【以下主要用于对所需时间变量的输出】#include <dos.h>
#include <stdio.h>
int main(void)
{
struct date d;
struct time t;
getdate(&d);
gettime(&t);
printf(“The current year is: %d\n”,d.da_year); /此变量单输出年/
printf(“The current month is: %d\n”,d.da_mon); /此变量单输出月/
printf(“The current day is: %d\n”,d.da_day); /此变量单输出日/
printf(“The current time is: %2d:%02d:%02d.%02d\n”,t.ti_hour, t.ti_min, t.ti_sec, t.ti_hund); /时间变量分别输出是时、分、秒及秒以下的单位/ return 0;
}
输出时间函数使用
最新推荐文章于 2023-01-15 16:28:55 发布