#include
struct date {
int month;
int day;
int year;
};
int main(int argc, char const *argv[])
{
struct date today = {03,17,2019};
struct date thismonth = {.month=3, .year=2019};
printf("Today's date is %i-%i-%i.\n",
today.year,today.month,today.day);
printf("This month is %i-%i-%i.\n",
thismonth.year,thismonth.month,thismonth.day);
return 0;
}
初学者QWQ打扰啦
struct date today = {03,17,2019};不是所有编译器都支持这么写
你可以用标准写法
date today;
today.month = 3;
today.day = 17;
today.tear = 2019;
下面的类似