用 DATA 代替结构体变量名:
#include <stdio.h>
typedef struct // <----
{
int year;
int month;
int day;
}DATE; // <----
int main()
{
DATE time={2021,3,4}; // <----
printf("%d年%d月%d日\n\n",time.year,time.month,time.day);
return 0;
}
与以下等价:
#include <stdio.h>
struct Date // <----
{
int year;
int month;
int day;
}; // <----
int main()
{
struct Date time={2021,3,4}; // <----
printf("%d年%d月%d日\n\n",time.year,time.month,time.day);
return 0;
}