| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 328 人关注过本帖
标题:求帮忙看看通讯录代码哪儿错了 顺便帮忙写下删除函数的代码
取消只看楼主 加入收藏
tianxintong
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2011-3-30
结帖率:50%
收藏
 问题点数:0 回复次数:0 
求帮忙看看通讯录代码哪儿错了 顺便帮忙写下删除函数的代码
#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;
}
搜索更多相关主题的帖子: 通讯录 email 
2011-04-02 11:56
快速回复:求帮忙看看通讯录代码哪儿错了 顺便帮忙写下删除函数的代码
数据加载中...
 
   



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

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