一个c语言的日历显示程序

2024-11-09 09:33:22
推荐回答(1个)
回答(1):

#include
#include
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);
}