我用C语言写了一个平年闰年的问题,但是我把a定义成字符串了之后显示报错,但是当n是闰年的时候我打出来的是字,当n是平年的时候,输出的是数字零,所以我把a定义成字符串,请问为什么不对?
#include <stdio.h>
#include <stdlib.h>
int temp(int n){
if((n%100!=0&&n%4==0)||n%400==0){
printf("闰年");
// system("pause")
}
else{
return 0;
}
}
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char *argv[]) {
int n;
str a;
scanf("%d",&n);
a=temp(n);
printf("%s",a);
return 0;
}