user-0 提问: 通讯录管理系统，我编出来的程序有以下的一些问题，请高手指正，谢谢！

回复:
user: user-1
content: 1.main函数里你的while(1)放错位置了 2.show函数里的你的这个用法有问题，你int n;以后，根本没有赋过值然后就使用了  #include <stdio.h> #include <string.h> #include <stdlib.h> #include <conio.h> #define N 5 struct person { 	char name[5]; 	char addr[5]; 	char  tel[10]; 	char email[5]; }per[N];  void insert(); void modify(); void cancel(); void show(); void search(); void sort(); void read(); void printf_n(int n);  void menu() { 	int n, w; 	do 	{ 		puts("\t\t******************Here is the menu.********************\n"); 		puts("\t\t\t\t 1.insert\n"); 		puts("\t\t\t\t 2.modify\n"); 		puts("\t\t\t\t 3.cancel\n"); 		puts("\t\t\t\t 4.show\n"); 		puts("\t\t\t\t 5.sort\n"); 		puts("\t\t\t\t 6.search\n"); 		puts("\t\t\t\t 7.name\n"); 		puts("\t\t\t\t 8.addr\n"); 		puts("\t\t\t\t 9.tel\n"); 		puts("\t\t\t\t 10.email\n"); 		puts("\t\t*********Please input the number you need.*************\n\n"); 		scanf("%d", &n); 		if (n<0 || n>7) 		{ 			w = 1; 			getchar(); 		} 		else w = 0; 	} while (w == 1); 	switch (n) 	{ 	case 1:insert(); break; 	case 2:modify(); break; 	case 3:cancel(); break; 	case 4:show(); break; 	case 5:sort(); break; 	case 6:search(); break; 	} }  void main() { 	int n, w; 	do 	{ 		puts("\t\t***************Here is the menu.***************\n"); 		puts("\t\t\t\t 1.insert\n"); 		puts("\t\t\t\t 2.modify\n"); 		puts("\t\t\t\t 3.cancel\n"); 		puts("\t\t\t\t 4.show\n"); 		puts("\t\t\t\t 5.sort\n"); 		puts("\t\t\t\t 6.search\n"); 		puts("\t\t\t\t 7.name\n"); 		puts("\t\t\t\t 8.addr\n"); 		puts("\t\t\t\t 9.tel\n"); 		puts("\t\t\t\t 10.email\n"); 		puts("\t\t*********Please input the number you need.*****\n\n"); 		scanf("%d", &n); 		switch (n) 		{ 		case 1:insert(); break; 		case 2:modify(); break; 		case 3:cancel(); break; 		case 4:show(); break; 		case 5:sort(); break; 		case 6:search(); break; 		} 		 	} while (1); }  void printf_back() { 	int w; 	printf("\n\nSuccessful.^_^\n\n"); 	printf("\t\t****** What do you wan to do? ******\n\nt1).Exit\t2.Back:[ ]\b\b"); 	scanf("%d", &w); 	if (w == 1) exit(0); 	else menu(); }  void show() { 	int n; 	read(); 	printf_n(n); 	printf_back(); }  void read() { 	FILE*fp; 	int i; 	if ((fp = fopen("person.txt", "r")) == NULL) 	{ 		printf("\nCan't open this file.\n"); 		exit(0); 	} 	for (i = 0; !feof(fp); i++) 		fscanf(fp, "%s %s %s %s", per[i].name, per[i].addr, per[i].tel, per[i].email); 	fclose(fp); 	printf_back(); }  void printf_one(int i) { 	printf("%s %s %s %s\n", per[i].name, per[i].addr, per[i].tel, per[i].email); }  void printf_n(int n) { 	int j; 	for (j = 0; j < n; j++) 	{ 		printf_one(j); 	}  }  void insert() { 	int i, n, M; 	printf("Please input the number of person you want to add.\n"); 	scanf("%d", &n); 	M = n + N; 	printf("Please input the detailed information.\n"); 	for (i = 1; i <= n; i++) 	{ 		printf("Name: \n"); 		scanf("%s", per[N - n - 1 - i].name); 		printf("Addr: \n"); 		scanf("%s", &per[N - n - 1 - i].addr); 		printf("Tel: \n"); 		scanf("%d", &per[N - n - 1 - i].tel); 		printf("Email: \n"); 		scanf("%s", &per[N - n - 1 - i].email); 	} 	printf_back(); }  void modify() { 	char m[5], p; 	int q; 	printf("Please input the name you want to modify.\n"); 	scanf("%s", &m); 	for (p = 0; p < N; p++) 	{ 		if (strcmp(m, per[p].name) == 0) 			printf("Please input the word you want to modify.\n"); 		scanf("%d", &q); 	} 	switch (q) 	{ 	case (7) : printf("Please input the new name.\n"); 		scanf("%s", per[p].name); 		printf("The new name is: \n", per[p].name); 		break; 	case (8) : printf("Plesae input the new address.\n"); 		scanf("%s", &per[p].addr); 		printf("The new address is: \n", per[p].addr); 		break; 	case (9) : printf("Plesae input the new tellphone number.\n"); 		scanf("%d", &per[p].tel); 		printf("The new tellphone number is: \n", per[p].tel); 		break; 	case (10) : printf("Plesae input the new email.\n"); 		scanf("%s", &per[p].email); 		printf("The new email is: \n", per[p].email); 		break; 	} 	printf_back(); }  void search() { 	char j[5]; 	int  k; 	printf("Please input the name you want to search.\n"); 	scanf("%s", &j); 	for (k = 0; k < N; k++) 	{ 		if (strcmp(j, per[k].name) == 0) 			printf("%s %s %s %s", per[k].name, per[k].addr, per[k].tel, per[k].email); 		else printf("Can't find it!\n"); 	} 	printf_back(); }  void cancel() { 	int x; 	char k[5]; 	printf("Please input the name you want to remove.\n"); 	scanf("%s", &k); 	for (x = 0; x < N; x++) 	{ 		if (strcmp(k, per[x].name) == 0) 		{ 			per[x] = per[x + 1]; 			printf("Succeed removing!\n"); 		} 		else printf("Can't find it!\n"); 	} 	printf_back(); }  void sort() { 	int i; 	char t[5]; 	for (i = 0; i < N; i++) 	{ 		if (strcmp(per[i].name, per[i + 1].name) < 0) 		{ 			strcpy(t, per[i].name); 			strcpy(per[i].name, per[i + 1].name); 			strcpy(per[i + 1].name, t);  		} 	} 	printf_back(); }

user: user-2
content: 你的main函数中只有一个do， 后面没有while  需要 do...while    void main() {  	int n,w; 	do 	{ 		puts("\t\t***************Here is the menu.***************\n"); 		puts("\t\t\t\t 1.insert\n"); 		puts("\t\t\t\t 2.modify\n"); 		puts("\t\t\t\t 3.cancel\n"); 		puts("\t\t\t\t 4.show\n"); 		puts("\t\t\t\t 5.sort\n"); 		puts("\t\t\t\t 6.search\n"); 		puts("\t\t\t\t 7.name\n"); 		puts("\t\t\t\t 8.addr\n"); 		puts("\t\t\t\t 9.tel\n"); 		puts("\t\t\t\t 10.email\n"); 		puts("\t\t*********Please input the number you need.*****\n\n"); 		scanf("%d",&n); 		switch(n) 		{ 		case 1:insert();break; 		case 2:modify();break; 		case 3:cancel();break; 		case 4:show();break; 		case 5:sort();break; 		case 6:search();break; 		} 		while(1); 	} while(...);  ///////把这里填了 }

user: user-0
content: 我把main函数放在最后之后，只有main函数的最后一个花括号被报错，说是syntax error : '}'，但是我数了一下花括号的个数是对的，不知道哪里出了问题

user: user-0
content: 谢谢，我把remove重新换了一个名字后，仍有两个错误。但是我发现不出哪里有问题，可以再看一下吗 #include <stdio.h> #include <string.h> #include <stdlib.h> #include <conio.h> #define N 5 struct person  { 	char name[5]; 	char addr[5]; 	char  tel[10]; 	char email[5]; }per[N];  void insert(); void modify(); void cancel(); void show(); void search(); void sort(); void read(); void printf_n(int n);  void menu() { int n,w;  do  {  puts("\t\t******************Here is the menu.********************\n");  puts("\t\t\t\t 1.insert\n");  puts("\t\t\t\t 2.modify\n");  puts("\t\t\t\t 3.cancel\n");  puts("\t\t\t\t 4.show\n");  puts("\t\t\t\t 5.sort\n");  puts("\t\t\t\t 6.search\n");  puts("\t\t\t\t 7.name\n");  puts("\t\t\t\t 8.addr\n");  puts("\t\t\t\t 9.tel\n");  puts("\t\t\t\t 10.email\n");  puts("\t\t*********Please input the number you need.*************\n\n");  scanf("%d",&n);  if(n<0||n>7)  { 	 w=1; 	 getchar();  }  else w=0;  }  while(w==1);  switch(n)  {  case 1:insert();break;  case 2:modify();break;  case 3:cancel();break;  case 4:show();break;  case 5:sort();break;  case 6:search();break;  } }  void main() {	int n,w; 	do 	{ 		puts("\t\t***************Here is the menu.***************\n"); 		puts("\t\t\t\t 1.insert\n"); 		puts("\t\t\t\t 2.modify\n"); 		puts("\t\t\t\t 3.cancel\n"); 		puts("\t\t\t\t 4.show\n"); 		puts("\t\t\t\t 5.sort\n"); 		puts("\t\t\t\t 6.search\n"); 		puts("\t\t\t\t 7.name\n"); 		puts("\t\t\t\t 8.addr\n"); 		puts("\t\t\t\t 9.tel\n"); 		puts("\t\t\t\t 10.email\n"); 		puts("\t\t*********Please input the number you need.*****\n\n"); 		scanf("%d",&n); 		switch(n) 			{ 				case 1:insert();break; 				case 2:modify();break; 				case 3:cancel();break; 				case 4:show();break; 				case 5:sort();break; 				case 6:search();break; 			} 		while(1); 	} }  void printf_back() { 	int w; 	printf("\n\nSuccessful.^_^\n\n"); 	printf("\t\t****** What do you wan to do? ******\n\nt1).Exit\t2.Back:[ ]\b\b"); 	scanf("%d",&w); 	if(w==1) exit(0); 	else menu(); }  void show() {    	int n; 	read();     printf_n(n); 	printf_back(); }  void read() { 	FILE*fp; 	int i; 	if((fp=fopen("person.txt","r"))==NULL) 	{ 		printf("\nCan't open this file.\n"); 		exit (0); 	}     for(i=0;!feof(fp);i++) 		fscanf(fp,"%s %s %s %s",per[i].name,per[i].addr,per[i].tel,per[i].email);     fclose(fp); 	printf_back(); }  void printf_one(int i) { 	printf("%s %s %s %s\n",per[i].name,per[i].addr,per[i].tel,per[i].email); }  void printf_n(int n) { 	int j; 	for(j=0;j<n;j++) 	{ 		printf_one(j); 	}	  }  void insert() {   int i,n,M; 	printf("Please input the number of person you want to add.\n"); 	scanf("%d",&n); 	M=n+N;     printf("Please input the detailed information.\n"); 	for(i=1;i<=n;i++) 	{ 		printf("Name: \n"); 		scanf("%s",per[N-n-1-i].name); 		printf("Addr: \n"); 		scanf("%s",&per[N-n-1-i].addr); 		printf("Tel: \n"); 		scanf("%d",&per[N-n-1-i].tel); 		printf("Email: \n"); 		scanf("%s",&per[N-n-1-i].email); 	} 	printf_back(); }  void modify() { 	char m[5],p; 	int q; 	printf("Please input the name you want to modify.\n"); 	scanf("%s",&m); 	for(p=0;p<N;p++) 	{	 		if(strcmp(m,per[p].name)==0) 		printf("Please input the word you want to modify.\n"); 		scanf("%d",&q); 	} 	switch(q) 	{ 	case (7):printf("Please input the new name.\n"); 		     scanf("%s",per[p].name); 			 printf("The new name is: \n",per[p].name); 			 break; 	case (8):printf("Plesae input the new address.\n"); 		     scanf("%s",&per[p].addr); 		     printf("The new address is: \n",per[p].addr); 			 break; 	case (9):printf("Plesae input the new tellphone number.\n"); 		     scanf("%d",&per[p].tel); 			 printf("The new tellphone number is: \n",per[p].tel); 			 break; 	case (10):printf("Plesae input the new email.\n"); 			  scanf("%s",&per[p].email);               printf("The new email is: \n",per[p].email); 			  break; 	} 	printf_back(); }  void search() { 	char j[5]; 	int  k; 	printf("Please input the name you want to search.\n"); 	scanf("%s",&j); 	for(k=0;k<N;k++) 	{ 		if(strcmp(j,per[k].name)==0) 			printf("%s %s %s %s",per[k].name,per[k].addr,per[k].tel,per[k].email); 		else printf("Can't find it!\n"); 	} 	printf_back(); }  void cancel() { 	 int x; 	 char k[5]; 	 printf("Please input the name you want to remove.\n"); 	 scanf("%s",&k); 	 for(x=0;x<N;x++) 	 { 		 if(strcmp(k,per[x].name)==0)  		 { 		  per[x]=per[x+1]; 		  printf("Succeed removing!\n");          } 		 else printf("Can't find it!\n"); 	 }      printf_back();  }  void sort() {     int i; 	char t[5];     for(i=0;i<N;i++) 	{ 	 if(strcmp(per[i].name,per[i+1].name)<0)  	 { 		 strcpy(t,per[i].name); 		 strcpy(per[i].name,per[i+1].name); 		 strcpy(per[i+1].name,t);  	 } 	} 	printf_back(); }  *****************************************Debug****************************************************** c:\program files (x86)\microsoft visual studio\myprojects\ghjkj\rfghgj.c(88) : error C2059: syntax error : '}' c:\program files (x86)\microsoft visual studio\myprojects\ghjkj\rfghgj.c(105) : warning C4013: 'printf_back' undefined; assuming extern returning int 执行 cl.exe 时出错.

user: user-3
content: 头文件： stdio.h  中也有一个remove()函数，用于删除指定的文件，其原型如下： int remove(char * filename);  你的程序中也有一个同名函数：void remove();