#include<stdio.h>
struct date{
int month;
int year;
int day;
};
int main(int argc,char const *argv[])
{
struct date today = {09,2022,25};
struct date thismonth = {.month=9,.year=2022};
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;
}
以上代码会出现 警告 [Error] invalid digit "9" in octal constant,我知道是0开头的数字,比如‘09’表示八进制(oct)数;但是为什么下面代码里的‘07’就没有出现警告?
#include<stdio.h>
struct date {
int month;
int day;
int year;
};
int main(int argc,char const *argv[])
{
struct date today;
today = (struct date){07,31,2014}; //对today赋值
struct date day; //定义结构变量day
day = today; //将today的值赋给day
printf("Today's date is %i-%i-%i.\n",
today.year,today.month,today.day);
printf("The day's date is %i-%i-%i.\n",
day.year,day.month,day.day);
return 0;
}