如何修改这个编程中的错误
给出年月日,编写函数,计算该日是该年的第几天。拜托各位大神帮忙看下这几个错误该如何修改
cpp(3) : warning C4518: 'int ' : storage-class or type specifier(s) unexpected here; ignored
cpp(3) : error C2146: syntax error : missing ';' before identifier 'main'
cpp(3) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.
#include<stdio.h>
void date(int year ,int month,int day)
int main()
{ int year,month,day;
scanf("%d,%d,%d",&year,&month,&day);
date(year,month,day);
return 0;
}
void date(int year,int month,int day)
{int month[12],sum,i;
for(i=0;month<1||month>12&&month==2&&day>29||day<1||day>31;i++)
{printf("Error!\n");
scanf("%d,%d,%d",&year,&month,&day);
}
for(i=0;i<12;i++)
{if((i==1)&&(year%4==0&&year%100!=0)||(year%400==0))
month[i]=29;
else if
month[i]=28;
else if(i==0||i==2||i==4||i==6||i==7||i==9||i==11)
month[i]=31;
else
month[i]=30;
}
for(i=0,sum=0;i<month-1;sum+=month[i++])
sum+=day;
printf("%d is No.%d day in%d\n",day,sum,year);
}