user-0 提问: 谁帮忙调试这段c代码 编译环境c-free

回复:
user: user-1
content: #include <stdio.h>  #define NUM 30  typedef struct { //日期结构体     int year;     int month;     int day; }DATE;  typedef struct{//学生信息结构     int num;     char name[24];     DATE birthday;  //结构体嵌套     char department[48];     char major[32]; }STUDENTINFO;  void inputInfo(STUDENTINFO s[]);  //函数声明 void outputInfo(STUDENTINFO s[]); //函数声明 void searchInfo(STUDENTINFO s[],DATE); //函数声明  int main() {     STUDENTINFO s[NUM]; //学生结构体变量     DATE date; //日期结构体变量      inputInfo(s);     outputInfo(s);     printf("\n Enter a date(month,day)");     scanf("%d%d",&date.month,&date.day);     searchInfo(s,date);      return 0; }  //输入全部学生的信息 void inputInfo(STUDENTINFO s[]) {     int i;     printf("\nEnter %d student's information(name,birthday,department,major)\n",NUM);     for(i=0;i<NUM;i++){         s[i].num=i+1;         scanf("%s",s[i].name);         scanf("%d%d%d", &s[i].birthday.year,&s[i].birthday.month,&s[i].birthday.day);         scanf("%s", s[i].department);         scanf("%s", s[i].major);     } }  //输出全部学生的信息 void outputInfo(STUDENTINFO s[]) {     int i;     printf("\n NUM Name Birthday Department Major\n");     for(i=0;i<NUM;i++){         //printf("\n%4d%14s %4d%2d%2d%16s%16s",s[i].NUM,s[i].name,s[i].birthday.year,s[i].birthday.month,s[i].birthday.day,s[i].department,s[i].major);         printf("\n%4d%14s %4d%2d%2d%16s%16s",s[i].num,s[i].name,s[i].birthday.year,s[i].birthday.month,s[i].birthday.day,s[i].department,s[i].major);     } }  //查找并输出date之后过生日的学生信息 void searchInfo(STUDENTINFO s[],DATE date) {     int i;     for(i=0;i<NUM;i++){         if(s[i].birthday.month > date.month){             printf("\n%16s %4d %2d%2d",s[i].name,s[i].birthday.year,s[i].birthday.month,s[i].birthday.day);             continue;         }         if(s[i].birthday.month== date.month && s[i].birthday.day>date.day){             printf("\n%4d%16s %2d%2d",s[i].num,s[i].name,s[i].birthday.month,s[i].birthday.day);         }     } } 参考一下吧 问题1：inputInfo函数定义两次，第二次应该改成outputInfo 问题2：s[i]没有NUM结构体元素，应该改成小写； 问题3：searchInfo函数中，s[i].name应该对应的是%s，而不是%d 对比一下吧；写程序建议细心一些～

user: user-2
content: #include <stdio.h>  #define NUM 30 typedef struct { //日期结构体  	int year; 	int month; 	int day; }DATE;  typedef struct {//学生信息结构  	int num; 	char name[24]; 	DATE birthday;  //结构体嵌套  	char department[48]; 	char major[32]; }STUDENTINFO;  void inputInfo(STUDENTINFO* s,int count);  //函数声明  void outputInfo(STUDENTINFO* s,int count); //函数声明 void searchInfo(STUDENTINFO* s,int count, DATE date); //函数声明    int main() { 	STUDENTINFO s[NUM]; //学生结构体变量  	DATE date; //日期结构体变量  	inputInfo(s, NUM); 	outputInfo(s,NUM); 	printf("\n Enter a date(month,day)"); 	scanf("%d%d", &date.month, &date.day); 	searchInfo(s,NUM, date); }  //输入全部学生的信息 void inputInfo(STUDENTINFO* s,int count) { 	int i; 	printf("\nEnter %d student's information(name,birthday,department,major)\n", count); 	for (i = 0; i<count; i++) { 		s[i].num = i + 1; 		scanf("%s", s[i].name); 		scanf("%d%d%d", &s[i].birthday.year, &s[i].birthday.month, &s[i].birthday.day); 		scanf("%s", s[i].department); 		scanf("%s", s[i].major); 	} }  //输出全部学生的信息 void outputInfo(STUDENTINFO* s, int count) { 	int i; 	printf("\n NUM Name Birthday Department Major\n"); 	for (i = 0; i<count; i++) { 		printf("\n%4d%14s %4d%2d%2d%16s%16s", s[i].num, s[i].name, s[i].birthday.year, s[i].birthday.month, s[i].birthday.day, s[i].department, s[i].major); 	} }  //查找并输出date之后过生日的学生信息  void searchInfo(STUDENTINFO* s,int count, DATE date) { 	int i; 	for (i = 0; i<count; i++) { 		if (s[i].birthday.month>date.month) { 			printf("\n%4d%16s %2d%2d",  s[i].birthday.year, s[i].name, s[i].birthday.month, s[i].birthday.day); 			continue; 		} 		if (s[i].birthday.month == date.month&&s[i].birthday.day>date.day) { 			printf("\n%4d%16s %2d%2d", s[i].num, s[i].name, s[i].birthday.month, s[i].birthday.day); 		} 	} }