| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 408 人关注过本帖
标题:通讯录的修改函数,错误在那里?
取消只看楼主 加入收藏
maiiho
Rank: 1
等 级:新手上路
帖 子:94
专家分:7
注 册:2008-7-17
结帖率:50%
收藏
 问题点数:0 回复次数:0 
通讯录的修改函数,错误在那里?
xg()                                 /*修改函数*/
{
   struct xx XX;
   FILE *fp1,*fp2;
   int flag;
   char ch[15];
   int a;
   if((fp1=fopen("xinxi.txt","rb"))==NULL)
   {
        printf("错误!不能打开记录文件(xinxi.txt)!");
        getch();
        main();
        }
    if((fp2=fopen("temp.txt","wb"))==NULL)
    {
       printf("错误!不能打开记录文件(temp.txt)!");
        getch();
        main();
        }
        printf("要修改谁(输入名字):");
        gets(ch);
        getchar();
        flag=0;
        while(fread(&XX,sizeof(XX),1,fp1)==1)
        {
          if(strcmp(ch,XX.xingming)==0)
          {
            printf("\n姓名:%s\n",XX.xingming);
            printf("性别 :%s\n",XX.xingbie);
            printf("电话 :%s\n",XX.dianhua);
            printf("QQ :%s\n",XX.qq);
            printf("E-M :%s",XX.email);
            printf("\n\n\n按任意键,输入新记录!\n");
            getch();
            printf("姓名:");
            gets(XX.xingming);
            printf("性别:");
            gets(XX.xingbie);
            printf("电话:");
            gets(XX.dianhua);
            printf("QQ:");
            gets(XX.qq);
            printf("E-mail:");
            gets(XX.email);
            flag=1;
            }
            fwrite(&XX,sizeof(XX),1,fp2);
            }
            fclose(fp1);
            fclose(fp2);
            if(flag==1)
            {
              printf("Modify sucess!\n");
              remove("xinxi.txt");
              rename("temp.txt","xinxi.txt");
              }
              else
              printf("找不到这个记录!\n");
              getch();
              printf("1.继续||2.返回||3.退出-->[ ]\b\b");
              scanf("%d",&a);
              if(a==1)
              {
            system("cls");
              xg();
              }
              else if(a==2)
              {
                 main();
                 }
                 else if(a==3)
                 {
                   exit(0);
                   }
              }
搜索更多相关主题的帖子: 修改 
2008-08-24 05:07
快速回复:通讯录的修改函数,错误在那里?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015740 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved