主题:关于结构体变量的题,有一个错误,不懂~
#include<stdio.h>
{
struct dates
{
int year;
int month;
int day;
}
dates y_m_d;
void main()
{
struct dates y_m_d;
struct dates *p;
int n;
printf("请输入年份,月份,日期:\n");
scanf("%d%d%d",&y_m_d.year,&y_m_d.month,&y_m_d.day);
p=&y_m_d;
switch((*p)->month)
{
case 1:n=(*p)->day;break;
case 2:n=(*p)->day;break;
case 3:n=(*p)->day+31;break;
case 4:n=(*p)->day+59;break;
case 5:n=(*p)->day+90;break;
case 6:n=(*p)->day+120;break;
case 7:n=(*p)->day+151;break;
case 8:n=(*p)->day+181;break;
case 9:n=(*p)->day+212;break;
case 10:n=(*p)->day+243;break;
case 11:n=(*p)->day+273;break;
case 12:n=(*p)->day+334;break;
default:break;
}
if(((*p)->year)%4==0&&(*p)->year%100!=0||((*p)->year)%400)==0)
n+=1;
printf("%d月%d号在%d年中是第%d天\n",(*p)->month,(*p)->day,(*p)->year,n);
}
}
有一个错误是:cpp(2) : error C2447: missing function header (old-style formal list?)
这是什么意思啊?还想问的是,如果把struct前的括号去掉或者是写成
struct dates
{
int year;
int month;
int day;
};
void main()
{struct dates y_m_d;
.........}
会有89个错误!难道这样定义结构体变量不对吗??请教我一下~谢谢~
{
struct dates
{
int year;
int month;
int day;
}
dates y_m_d;
void main()
{
struct dates y_m_d;
struct dates *p;
int n;
printf("请输入年份,月份,日期:\n");
scanf("%d%d%d",&y_m_d.year,&y_m_d.month,&y_m_d.day);
p=&y_m_d;
switch((*p)->month)
{
case 1:n=(*p)->day;break;
case 2:n=(*p)->day;break;
case 3:n=(*p)->day+31;break;
case 4:n=(*p)->day+59;break;
case 5:n=(*p)->day+90;break;
case 6:n=(*p)->day+120;break;
case 7:n=(*p)->day+151;break;
case 8:n=(*p)->day+181;break;
case 9:n=(*p)->day+212;break;
case 10:n=(*p)->day+243;break;
case 11:n=(*p)->day+273;break;
case 12:n=(*p)->day+334;break;
default:break;
}
if(((*p)->year)%4==0&&(*p)->year%100!=0||((*p)->year)%400)==0)
n+=1;
printf("%d月%d号在%d年中是第%d天\n",(*p)->month,(*p)->day,(*p)->year,n);
}
}
有一个错误是:cpp(2) : error C2447: missing function header (old-style formal list?)
这是什么意思啊?还想问的是,如果把struct前的括号去掉或者是写成
struct dates
{
int year;
int month;
int day;
};
void main()
{struct dates y_m_d;
.........}
会有89个错误!难道这样定义结构体变量不对吗??请教我一下~谢谢~