求帮忙看看通讯录代码哪儿错了 顺便帮忙写下删除函数的代码
#include<stdio.h>#include<string.h>
#include<stdlib.h>
#include<conio.h>
struct xx
{
char xingming[15];
char xingbie[5];
char dianhua[13];
char qq[13];
char email[30];
};
int printf1()
{
int i;
clrscr();
printf("\t\t\t\t tong xun lu");
printf("----------------------------------");
printf("1liulan");
printf("2tianjia");
printf("3xiugai");
printf("4chazhao");
printf("5shanchu");
printf("6tuichu");
printf("\n--------------------------------");
printf("wo yao xuan ze:");
scanf("%d",&i);return i;
}
tj()
{
int a;
struct xx ;
FILE *fp
if((fp=fopen("xinxi.txt"),"wb")==NULL)
{
printf("error....\n");
getch();
main();
}
printf("shu ru xing ming:");
gets(xx.xingming);
printf("shu ru xing bie:");
gets(xx.xingbie);
printf("shu ru dian hua:");
gets(xx.dianhua);
printf("shu ru qq:");
gets(xx.qq);
printf("shu ru email:");
gets(xx.email);
fclose(fp);
printf("\n1.fanhui--2.tianjia--3.tuichu");
scanf("%d",&a);
if(a==1)
{
main();
}
else if(a==2)
{
tj();
}
else if(a==3)
{
exit(0);
}
else
{
printf("error");
getch();
main();
}
}
xs()
{
int i;
struct xx ;
FILE *fp
if((fp=fopen("xinxi.txt"),"rb")==NULL)
{
printf("error....\n");
getch();
main();
}
while(fread(&xx,sizeof(xx),1,fp)==1)
{
printf("xingming:%s\n",xx.xingming);
printf("xingbie:%s\n",xx.xingbie);
printf("dianhuo:%s\n",xx.dianhua);
printf("qq:%s\n",xx.qq);
printf("email:%s\n",xx.email);
}
fclose(fp);
printf("1.fanhui 2.tuichu");
scanf("%d",&i);
if(i==1)
{
main();
}
else if(i==2)
{
exit(0);
}
else
{
getch();
clrscr();
xs();
}
}
xg()
{
struct xx;
FILE *fp1,fp2;
int flag;
char name;
int a;
if((fp1=fopen("xinxi.txt"),"wb")==NULL)
{
printf("error....\n");
getch();
main();}
if((fp2=fopen("temp.txt"),"wb")==NULL)
{
printf("error....\n");
getch();
main();}
printf("shu ru name:");
scanf("%s",&name);
flag=0;
while(fread(&xx.sizeof(xx),1,fp1)==1)
{
if(strcmp(name,xx.xingming)==0)
{
printf("xingming:%s\n",xx.xingming);
printf("xingbie:%s\n",xx.xingbie);
printf("dianhuo:%s\n",xx.dianhua);
printf("qq:%s\n",xx.qq);
printf("email:%s\n",xx.email);
printf("shu ru xin nei rong:");
printf("shu ru xing ming:");
gets(xx.xingming);
printf("shu ru xing bie:");
gets(xx.xingbie);
printf("shu ru dian hua:");
gets(xx.dianhua);
printf("shu ru qq:");
gets(xx.qq);
printf("shu ru email:");
gets(xx.email);
flag=1;
}
fwrite(&xx,sizeof(xx),1,fp2);
}
fclose(fp1);
fclose(fp2);
if(flag==1)
{
printf("sucess");
remove("xinxi.txt");
rename("temp.txt","xinxi.txt");
}
else printf("error");
getch();
printf("1.jixu 2.fanhui 3.tuichu");
scanf("%d",&b);
if(a==1)
{
clrscr();
xg();
}
else if(a==2)
{
main();
}
else if(a==3)
{
exit(0)
}
else printf("error");
clrscr();
xg();
}
cx()
{
struct xx;
FILE *fp;
int flag;
int total;
char ch;
int b,tel;
if((fp=fopen("xinxi.txt"),"ab")==NULL)
{
printf("error....\n");
getch();
main();}
rewind(fp);
printf("1.name 2.tel");
scanf("%d",&flag);
if(flag==1)
{
printf("shu ru xing ming");
scanf("%s",&ch);
total=0;
while(fread(&xx.sizeof(xx),1,fp)==1)
if(strcmp(ch,xx.xingming)==1)
{
total++;
if(total==1)
printf("xingming xingbie dainhua qq email",%sxx.xingming%sxx.xingbie%sxx.dianhua%sxx.qq%sxx.email);
}
}
if(flag==2)
{
printf("shu ru dianhua:");
scanf("%s",&tel);
total=0;
while(fread(&xx.sizeof(xx),1,fp)==1)
if(strcmp(tel,xx.dianhua)==0)
{
total++;
if(total==1)
printf("xingming xingbie dainhua qq email",%sxx.xingming%sxx.xingbie%sxx.dianhua%sxx.qq%sxx.email);
}
}
fclose(fp);
printf("1.fanhui 2.tuichu");
scanf("%d",&b);
if(b==1)
{
main();
}
else
{
exit(0);
}
}
sc()
{
}
main()
{
switch(printf1())
case 1:clrscr();xs();break;
case 2:clrscr();tj();break;
case 3:clrscr();xg();break;
case 4:clrscr();cx();break;
case 5:clrscr();sc();break;
case 6:exit(0);break;
}