C语言文件问题 谢谢

[复制链接]
查看11 | 回复6 | 2011-5-18 11:22:49 | 显示全部楼层 |阅读模式
#include\"stdio.h\"
#include\"stdlib.h\"
#include\"string.h\"
structad{
        charname[20];
        charadd[20];
}a[3];
structte{
        charname[30];
        chartel[30];
}t[3];
structat{
        charname[30];
        charaddress[30];
        charphone[30];
}addt[3];
voidmain()
{
        FILE*fp1,*fp2,*fp3;
        inti,j;
        if((fp1=fopen(\"E:\\\\Ccode\\\\add.txt\",\"a\"))=NULL)
        {
                printf(\"Filecan\'topen!\\n\");
                exit(0);
        }
        if((fp2=fopen(\"E:\\\\Ccode\\\\tel.txt\",\"a\"))=NULL)
        {
                printf(\"Filecan\'topen!\\n\");
                exit(0);
        }
        if((fp3=fopen(\"E:\\\\Ccode\\\\addtel.txt\",\"a\"))=NULL)
        {
                printf(\"Filecan\'topen!\\n\");
                exit(0);
        }
        for(i=0;i3;i)
        {
                fscanf(fp1,\"%s%s\",a.name,a.add);
                fscanf(fp2,\"%s%s\",t.name,t.tel);
        for(j=0;j3;j)
       
                strcmp(addt.name,a.name);
                for(j=0;j3;j)
                        if(strcmp(a.name,t[j].name)==0)
                        strcpy(addt.address,a.add);
                        //strcpy(addt[j].phone,t[j].tel);
       
        }
        fclose(fp1);
fclose(fp2);
fclose(fp3);
}
请看一下不能运行
回复

使用道具 举报

千问 | 2011-5-18 11:22:49 | 显示全部楼层
/*if((fp3=fopen(\"E:\\\\Ccode\\\\addtel.txt\",\"a\"))==NULL)//改成两个等号*/

#include\"stdio.h\"
#include\"stdlib.h\"
#include\"string.h\"
structad{
        charname[20];
        charadd[20];
}a[3];
structte{
        charname[30];
        chartel[30];
}t[3];
structat{
        charname[30];
        charaddress[30];
        charphone[30];
}addt[3];
voidmain()
{
        FILE*fp1,*fp2,*fp3;
        inti,j;
        if((fp1=fopen(\"E:\\\\Ccode\\\\add.txt\",\"a\"))==NULL)//改成两个等号
        {
                printf(\"Filecan\'topen!\\n\");
                exit(0);
        }
        if((fp2=fopen(\"E:\\\\Ccode\\\\tel.txt\",\"a\"))==NULL)//改成两个等号
        {
                printf(\"Filecan\'topen!\\n\");
                exit(0);
        }
        if((fp3=fopen(\"E:\\\\Ccode\\\\addtel.txt\",\"a\"))==NULL)//改成两个等号
        {
                printf(\"Filecan\'topen!\\n\");
                exit(0);
        }
        for(i=0;i3;i)
        {
                fscanf(fp1,\"%s%s\",a.name,a.add);
                fscanf(fp2,\"%s%s\",t.name,t.tel);
        for(j=0;j3;j)
       
                strcmp(addt.name,a.name);
                for(j=0;j3;j)
                        if(strcmp(a.name,t[j].name)==0)
                        strcpy(addt.address,a.add);
                        //strcpy(addt[j].phone,t[j].tel);
       
        }
        fclose(fp1);
fclose(fp2);
fclose(fp3);
}









<h4class=\"ask\">追问


改了也不行
回复

使用道具 举报

千问 | 2011-5-18 11:22:49 | 显示全部楼层
把邮箱给我吧,发给你,这写不下了。
回复

使用道具 举报

千问 | 2011-5-18 11:22:49 | 显示全部楼层
回复

使用道具 举报

千问 | 2011-5-18 11:22:49 | 显示全部楼层
已经发给你了,txt文件里。
回复

使用道具 举报

千问 | 2011-5-18 11:22:49 | 显示全部楼层
你CQUPT滴?
回复

使用道具 举报

千问 | 2011-5-18 11:22:49 | 显示全部楼层
嗯,你怎么知道的?看我QQ资料?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行