intf("please enter the name you want to modify:");
? ? ? ? gets(b);
? ? ? ? while((fread(&a,sizeof(info),1,fp1)) == 1)/*这里的sizeof()内容是否可以换为结构实例??*/
? ? ? ? {
? ? ? ? ? ? ? ? if(strcmp(b,a.name) == 0) /*要修改的内容 */
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? printf("\nplease enter the name you want to modify:");
? ? ? ? ? ? ? ? ? ? ? ? gets(a.name);
? ? ? ? ? ? ? ? ? ? ? ? printf("\nplease enter the phone you want to modify:");
? ? ? ? ? ? ? ? ? ? ? ? gets(a.phone);
? ? ? ? ? ? ? ? ? ? ? ? printf("\nplease enter the sex you want to modify:");
? ? ? ? ? ? ? ? ? ? ? ? gets(a.sex);
? ? ? ? ? ? ? ? ? ? ? ? printf("\nplease enter the age you want to modify:");
? ? ? ? ? ? ? ? ? ? ? ? gets(a.age);
? ? ? ? ? ? ? ? ? ? ? ? printf("\nplease enter the address you want to modify:");
? ? ? ? ? ? ? ? ? ? ? ? gets(a.address);
? ? ? ? ? ? ? ? ? ? ? ? fwrite(&a,sizeof(a),1,fp2);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? else
? ? ? ? ? ? ? ? ? ? ? ? fwrite(&a,sizeof(info),1,fp2);
? ? ? ? }
? ? fcloseall();
? ? ? ? getch();
? ? ? ? remove("information.txt");
? ? ? ? rename("temp.txt","information.txt");
}
void Delet()
{
? ? ? ? char f[20];
? ? ? ? char d[20];
? ? ? ? struct info a;
? ? ? ? FILE *fp1;
? ? ? ? FILE *fp2;
? ? ? ? printf("please enter the name you want to delet:");
? ? ? ? scanf("%s",d);
? ?
? ? ? ? if((fp1=fopen("information.txt","rb")) == NULL)
? ? ? ? {
? ? ? ? ? ? ? ? puts("errow open file!");
? ? ? ? ? ? ? ? getch();
? ? ? ? ? ? ? ? exit(1);
? ? ? ? }
? ? ? ? if((fp2=fopen("temp.txt","wb")) == NULL)
? ? ? ? {
? ? ? ? ? ? ? ? puts("errow open file!");
? ? ? ? ? ? ? ? getch();
? ? ? ? ? ? ? ? exit(1);
? ? ? ? }
? ? while((fread(&a,sizeof(info),1,fp1)) == 1)/*这里的sizeof()内容是否可以换为结构实例??*/
? ? ? ? {
? ? ? ? ? ? ? ? if(strcmp(d,a.name) != 0)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? fwrite(&a,sizeof(info),1,fp2);
? ? ? ? ? ? ? ? }
? ? ? ? }
? ? fcloseall();
? ? ? ? getch();
? ? ? ? remove("information.txt");
? ? ? ? rename("temp.txt","information.txt");
? ? ? ??
}
void Display()
{
? ? ? ? struct info a;
? ? ? ? FILE *fp;
? ? if((fp=fopen("information.txt","rb")) == NULL)
? ? ? ? {
? ? ? ? ? ? ? ? puts("errow opening file!!!");
? ? ? ? ? ? ? ? getch();
? ? ? ? ? ? ? ? exit(1);
? ? ? ? }
? ? ? ? Panel();
? ? ? ? puts("");
? ? ? ? while((fread(&a,sizeof(info),1,fp)) == 1)? ? ? ??
? ? ? ? ? ? ? ? FormatOutputInfo(a);
? ? ? ? getch();
? ? ? ? fclose(fp);
}
void Search()
{
? ? ? ? int c;
? ? ? ? char b[10];
? ? ? ? struct info a;
? ? ? ? FILE *fp;
? ? ? ? printf("please enter search mode [1]name [2]phone [3]sex [4]age [5]address:");
? ? ? ? scanf("%d",&c);
? ? switch(c)
? ? ? ? {
? ? ? ? case 1:
? ? ? ? ? ? ? ? printf("please enter the name you want to search:");
? ?? ???scanf("%s",b);
? ???? ? ? ? if((fp=fopen("information.txt","rb")) == NULL)
? ? ? ? ? ? ? ? {
? ? ? ?? ???? ? ? ? puts("errow opening file!!!");
? ? ? ?? ???? ? ? ? getch();
? ? ? ?? ?? ?? ? ? ? exit(1);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? Panel();
? ? ? ? ? ? puts("");
? ? ? ? ? ? while((fread(&a,sizeof(a),1,fp)) == 1)
? ? ? ? ? ? ? ? {
? ? ? ?? ???? ? ? ? if((strcmp(a.name,b))==0)
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ?? ???FormatOutputInfo(a);
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? getch();
? ? ? ? ? ? fclose(fp);
? ? ? ? ? ? ? ? break;
? ? ? ? case 2:
? ? ? ? ? ? ? ? printf("please enter the phone you want to Search:");
? ?? ???scanf("%s",b);
? ???? ? ? ? if((fp=fopen("information.txt","rb")) == NULL)
? ? ? ? ? ? ? ? {
? ? ? ?? ???? ? ? ? puts("errow opening file!!!");
? ? ? ?? ???? ? ? ? getch();
? ? ? ?? ?? ?? ? ? ? exit(1);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? Panel();
? ? ? ? ? ? puts("");
? ? ? ? ? ? while((fread(&a,sizeof(a),1,fp)) == 1)
? ? ? ? ? ? ? ? {
? ? ? ?? ???? ? ? ? if((strcmp(a.phone,b))==0)
? ? ? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ?? ???FormatOutputInfo(a);
? ? ? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? getch();
? ? ? ? ? ? fclose(fp |