用C语言编写一个程序显示日期
1个回答
展开全部
#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);
}
<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);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询