user-0 提问: 求助，函数调用却不执行

回复:
user: user-0
content: 引用 8 楼 user-1的回复: 嗯嗯，看懂了，谢谢啦

user: user-1

user: user-0
content: 引用 5 楼 user-1的回复:这是别人写的代码吧。能写出这么多的人应该不会犯这么低级的错误。  int main() { void creat();// 你确定是这么写的？  int choice=0; .... 好的，懂了。。。。。。。是我太傻了。。

user: user-0
content: 引用 5 楼 user-1的回复:这是别人写的代码吧。能写出这么多的人应该不会犯这么低级的错误。  int main() { void creat();// 你确定是这么写的？  int choice=0; .... 这是我自己写的。而且我还是没发现有什么问题。。

user: user-1
content: 这是别人写的代码吧。能写出这么多的人应该不会犯这么低级的错误。  int main() { void creat();// 你确定是这么写的？  int choice=0; ....

user: user-1
content: 为什么要发两遍代码。。。

user: user-0
content: 主函数不调用creat函数。

user: user-0
content: #include<stdio.h>  typedef struct member_infor { 	int book_num; 	char book_name[20]; 	char person[20]; 	int fine; 	int days; 	int sum_fine; 	int fine_rank; }book; book infor[15]; int n;   void creat(); void search(book infor[],int ); void search(book infor[],int ); void insert(book infor5[],book ); void del(book infor[],int ); void sum(book infor[]); void average(book infor[]); void sort(book infor[]); void print1(book infor[]); void print1(book infor[]); void print3(book infor[]);   void creat() { 	int i=0; 	n=0; 	FILE*fp; 	fp=fopen("返款信息.txt","r"); 	while(!feof(fp)) 	{ 		fscanf(fp,"%d %s %s %d %d %d %d",&infor[i].book_num,infor[i].book_name[20],infor[i].person[20], 			   &infor[i].fine,&infor[i].days,&infor[i].sum_fine,&infor[i].fine_rank); 		i++; 	} 	n=i-1;     infor[n+1].book_num=0; }  void search(book infor[],int number) { 	int i; 	while(infor[i].book_num!=number&&i<10) 	{ 		i++; 	} 	if(infor[i].book_num==number) 	{ 		printf("%d %s %s %d %d",infor[i].book_num,infor[i].book_name,infor[i].person,infor[i].fine, 		                    infor[i].days); 	} 	else printf("无此书"); }  void insert(book infor[],book new_book) { 	int i=0; 	int j=n; 	while(infor[i].book_num>new_book.book_num&&i<=n) 	{ 		i++; 	} 	if(infor[i].book_num<=new_book.book_num) 	{ 		for(;j>=i;j--) 		{ 			infor[j+1]=infor[j]; 		} 		infor[i]=new_book; 	} 	else infor[10]=new_book; 	infor[n+1].book_num=0; }  void del(book infor[],int number) { 	int i=0; 	int j=n; 	while(infor[i].book_num!=number&&i<=n) 	{ 		i++; 	} 	if(infor[i].book_num==number) 	{ 		for(;i<=n;i++) 		{ 			infor[i]=infor[i+1]; 		} 		infor[i].book_num=0; 		n--; 	} 	else printf("无此书"); }  void sum(book infor[]) { 	for(int i=0;i<n;i++) 	{ 		infor[i].sum_fine=infor[i].days*infor[i].fine; 	} }   void average(book infor[]) { 	float total=0; 	float aver=0; 	for(int i=0;i<n;i++) 	{ 	     total+=infor[i].sum_fine; 	} 	aver=total/n; 	printf("%d",aver); }  void sort(book infor[]) { 	int i; 	sum(infor); 	book temp; 	for(i=0;i<n-1;i++) 	{ 		for(int j=i+1;j<n;j++) 		if(infor[j].sum_fine<infor[i].sum_fine) 		{ 			temp=infor[j]; 			infor[j]=infor[i]; 			infor[i]=temp; 		} 	}     for(i=0;i<n;i++) 	{ 		infor[i].fine_rank=i; 	} }  void print1(book infor[15]) { 	for(int i=0;i<n;i++) 	{ 		printf("%d %s %s %d %d %d %d",infor[i].book_num,infor[i].book_name[20],infor[i].person[20], 			   infor[i].fine,infor[i].days); 	} }  void print2(book infor[15]) {      for(int i=0;i<n;i++) 	 { 		 printf("%d %s %s %d %d %d",infor[i].book_num,infor[i].book_name,infor[i].person,infor[i].fine, 		                    infor[i].days,infor[i].sum_fine); 	 } }  void print3(book infor[15]) {      for(int i=0;i<n;i++) 	 { 		 printf("%d %s %s %d %d %d %d",infor[i].book_num,infor[i].book_name,infor[i].person,infor[i].fine, 		                    infor[i].days,infor[i].sum_fine,infor[i].fine_rank); 	 } }  void creat(); int main() { void creat();  	int choice=0; 	while(choice!=7) 	{ 	printf("                   1.查找书"); 	printf("                   2.插入"); 	printf("                   3.删除"); 	printf("                   4.每本书罚款总额"); 	printf("                   5.总罚款平均值"); 	printf("                   6.排序"); 	printf("                   7.退出"); 	printf("选择菜单序号"); 	scanf("%d",&choice); 	switch(choice) 	{ 	case 1: 		int number; 		 		printf("输入书序号"); 		scanf("%d",&number); 		search(infor,number); 		break; 	case 2: 		book new_book; 		printf("输入一本书的罚款信息"); 		scanf("%d %s %s %d %d %d %d",&new_book.book_num,new_book.book_name[20],new_book.person[20], 			   &new_book.fine,&new_book.days,&new_book.sum_fine,&new_book.fine_rank); 		insert(infor,new_book); 		print1(infor); 		break; 	case 3:  		printf("输入书序号"); 		scanf("%d",&number); 		del(infor,number); 		print1(infor); 		break; 	case 4:  		sum(infor); 		print2(infor); 		break; 	case 5: 		average(infor); 		break; 	case 6: 		sum(infor); 		sort(infor); 		print3(infor); 		break; 	case 7: 		break; 	default:printf("无此选项，重选");break; 	} 	} 	return 0; }

user: user-0
content: #include<stdio.h>  typedef struct member_infor { 	int book_num; 	char book_name[20]; 	char person[20]; 	int fine; 	int days; 	int sum_fine; 	int fine_rank; }book; book infor[15]; int n;   void creat(); void search(book infor[],int ); void search(book infor[],int ); void insert(book infor5[],book ); void del(book infor[],int ); void sum(book infor[]); void average(book infor[]); void sort(book infor[]); void print1(book infor[]); void print1(book infor[]); void print3(book infor[]);   void creat() { 	int i=0; 	n=0; 	FILE*fp; 	fp=fopen("返款信息.txt","r"); 	while(!feof(fp)) 	{ 		fscanf(fp,"%d %s %s %d %d %d %d",&infor[i].book_num,infor[i].book_name[20],infor[i].person[20], 			   &infor[i].fine,&infor[i].days,&infor[i].sum_fine,&infor[i].fine_rank); 		i++; 	} 	n=i-1;     infor[n+1].book_num=0; }  void search(book infor[],int number) { 	int i; 	while(infor[i].book_num!=number&&i<10) 	{ 		i++; 	} 	if(infor[i].book_num==number) 	{ 		printf("%d %s %s %d %d",infor[i].book_num,infor[i].book_name,infor[i].person,infor[i].fine, 		                    infor[i].days); 	} 	else printf("无此书"); }  void insert(book infor[],book new_book) { 	int i=0; 	int j=n; 	while(infor[i].book_num>new_book.book_num&&i<=n) 	{ 		i++; 	} 	if(infor[i].book_num<=new_book.book_num) 	{ 		for(;j>=i;j--) 		{ 			infor[j+1]=infor[j]; 		} 		infor[i]=new_book; 	} 	else infor[10]=new_book; 	infor[n+1].book_num=0; }  void del(book infor[],int number) { 	int i=0; 	int j=n; 	while(infor[i].book_num!=number&&i<=n) 	{ 		i++; 	} 	if(infor[i].book_num==number) 	{ 		for(;i<=n;i++) 		{ 			infor[i]=infor[i+1]; 		} 		infor[i].book_num=0; 		n--; 	} 	else printf("无此书"); }  void sum(book infor[]) { 	for(int i=0;i<n;i++) 	{ 		infor[i].sum_fine=infor[i].days*infor[i].fine; 	} }   void average(book infor[]) { 	float total=0; 	float aver=0; 	for(int i=0;i<n;i++) 	{ 	     total+=infor[i].sum_fine; 	} 	aver=total/n; 	printf("%d",aver); }  void sort(book infor[]) { 	int i; 	sum(infor); 	book temp; 	for(i=0;i<n-1;i++) 	{ 		for(int j=i+1;j<n;j++) 		if(infor[j].sum_fine<infor[i].sum_fine) 		{ 			temp=infor[j]; 			infor[j]=infor[i]; 			infor[i]=temp; 		} 	}     for(i=0;i<n;i++) 	{ 		infor[i].fine_rank=i; 	} }  void print1(book infor[15]) { 	for(int i=0;i<n;i++) 	{ 		printf("%d %s %s %d %d %d %d",infor[i].book_num,infor[i].book_name[20],infor[i].person[20], 			   infor[i].fine,infor[i].days); 	} }  void print2(book infor[15]) {      for(int i=0;i<n;i++) 	 { 		 printf("%d %s %s %d %d %d",infor[i].book_num,infor[i].book_name,infor[i].person,infor[i].fine, 		                    infor[i].days,infor[i].sum_fine); 	 } }  void print3(book infor[15]) {      for(int i=0;i<n;i++) 	 { 		 printf("%d %s %s %d %d %d %d",infor[i].book_num,infor[i].book_name,infor[i].person,infor[i].fine, 		                    infor[i].days,infor[i].sum_fine,infor[i].fine_rank); 	 } }  void creat(); int main() {  	int choice=0; 	while(choice!=7) 	{ 	printf("                   1.查找书"); 	printf("                   2.插入"); 	printf("                   3.删除"); 	printf("                   4.每本书罚款总额"); 	printf("                   5.总罚款平均值"); 	printf("                   6.排序"); 	printf("                   7.退出"); 	printf("选择菜单序号"); 	scanf("%d",&choice); 	switch(choice) 	{ 	case 1: 		int number; 		 		printf("输入书序号"); 		scanf("%d",&number); 		search(infor,number); 		break; 	case 2: 		book new_book; 		printf("输入一本书的罚款信息"); 		scanf("%d %s %s %d %d %d %d",&new_book.book_num,new_book.book_name[20],new_book.person[20], 			   &new_book.fine,&new_book.days,&new_book.sum_fine,&new_book.fine_rank); 		insert(infor,new_book); 		print1(infor); 		break; 	case 3:  		printf("输入书序号"); 		scanf("%d",&number); 		del(infor,number); 		print1(infor); 		break; 	case 4:  		sum(infor); 		print2(infor); 		break; 	case 5: 		average(infor); 		break; 	case 6: 		sum(infor); 		sort(infor); 		print3(infor); 		break; 	case 7: 		break; 	default:printf("无此选项，重选");break; 	} 	} 	return 0; }