#C语言
请教大家,这样的应该怎么解决,刚刚开始学用Clion,这段代码明明在CB上运行是没有问题的。
报错为:
Call to undeclared function 'yearkind'; ISO C99 and later do not support implicit function declarations
Parameter 'year' was not declared, defaults to 'int'; ISO C99 and later do not support implicit int
以下为完整代码:
#include<stdio.h>
int main()
{
int ret, year, month, flag;
ret = scanf("%d %d", &year, &month);
if (ret != 2)
{
printf("ERROR!");
fflush(stdin);
}
else
{
flag = yearkind(year);
if (flag == 1) //闰年
{
switch(month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
printf("这个月有31天。");
break;
case 2:
printf("这个月有29天。");
break;
case 4:
case 6:
case 9:
case 11:
printf("这个月有30天。");
break;
}
}
else
{
switch(month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
printf("这个月有31天。");
break;
case 2:
printf("这个月有28天。");
break;
case 4:
case 6:
case 9:
case 11:
printf("这个月有30天。");
break;
}
}
}
return 0;
}
int yearkind(year)
{
return ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) ? 1 : 0;
}
我还想问一嘴,似乎CB的编码跟Clion不一样,怎么解决?