用C语言编写一个程序显示日期
发布网友
发布时间:2022-04-21 07:26
我来回答
共1个回答
热心网友
时间:2022-06-18 17:09
#include
<stdio.h>
#include
<windows.h>
main()
{
//定义一个时间结构存储时间数据;
SYSTEMTIME
*stm;
//定义了十二个月份的数组,用的时候直接调用
char
month[12][10]
=
{"January","February","March",
"April","May","June","July","August",
"September","October","November","December"};
//为时间结构体申请空间(c语言中必须)
stm
=
(SYSTEMTIME*)malloc(sizeof(SYSTEMTIME));
//获取系统时间
GetSystemTime(stm);
//显示时间
printf("%d\st
%s
%d",stm->wDay,month[stm->wMonth-1],stm->wYear);
}