| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 833 人关注过本帖
标题:编译文件操作时出现错误,帮忙看下原因,谢谢。。
只看楼主 加入收藏
zcs34989
Rank: 2
等 级:论坛游民
帖 子:34
专家分:34
注 册:2011-8-17
结帖率:100%
收藏
已结贴  问题点数:10 回复次数:6 
编译文件操作时出现错误,帮忙看下原因,谢谢。。
程序代码:
/*
    读取一个文件A,并写入文件B中
*/
# include <stdio.h>

int main(void)
{
    FILE *fpI = NULL;                                            //声明文件指针fpI,输入字符用
    fpI = fopen("E:\\Ctool\\product\\A.txt","rt");                //以只读文本方式打开txt文件
    if(fpI = NULL)                                                //放错处理
    {
        printf("输入文件打开失败,请检查");
        return 0;
    }
    FILE *fpO = NULL;
    fpO = fopen("E:\\Ctool\\product\\B.txt","wt");
    if(fpO = NULL)
    {
        printf("输出文件打开失败,请检查");
        return 0;
    }
    char temp = '\0';
    while(!feof(fpI))                                        //到达输入文件末尾时停止
    {
        temp = fgetc(fpI);
        if(temp != EOF)
            fputc(temp, fpO);
    }
    fclose(fpO);
    fclose(fpI);

    return 0;
}

win7系统用VC++6.0编译时,出现以下错误警告,我是照着书上输入的,不知道为什么会出现这些问题

--------------------Configuration: 文件操作 - Win32 Debug--------------------
Compiling...
文件操作.c
e:\ctool\product\文件操作.c(12) : error C2275: 'FILE' : illegal use of this type as an expression
        e:\ctool\ctool\vc++6.0\vc98\include\stdio.h(156) : see declaration of 'FILE'
e:\ctool\product\文件操作.c(12) : error C2065: 'fpO' : undeclared identifier
e:\ctool\product\文件操作.c(13) : warning C4047: '=' : 'int ' differs in levels of indirection from 'struct _iobuf *'
e:\ctool\product\文件操作.c(14) : warning C4047: '=' : 'int ' differs in levels of indirection from 'void *'
e:\ctool\product\文件操作.c(19) : error C2143: syntax error : missing ';' before 'type'
e:\ctool\product\文件操作.c(22) : error C2065: 'temp' : undeclared identifier
e:\ctool\product\文件操作.c(24) : warning C4047: 'function' : 'struct _iobuf *' differs in levels of indirection from 'int '
e:\ctool\product\文件操作.c(24) : warning C4024: 'fputc' : different types for formal and actual parameter 2
e:\ctool\product\文件操作.c(26) : warning C4047: 'function' : 'struct _iobuf *' differs in levels of indirection from 'int '
e:\ctool\product\文件操作.c(26) : warning C4024: 'fclose' : different types for formal and actual parameter 1
执行 cl.exe 时出错.

文件操作.obj - 1 error(s), 0 warning(s)

搜索更多相关主题的帖子: product 
2011-12-25 15:31
embed_xuel
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
等 级:贵宾
威 望:58
帖 子:3845
专家分:11385
注 册:2011-9-13
收藏
得分:2 
这几行代码不光有编译错还有逻辑运行错误

总有那身价贱的人给作业贴回复完整的代码
2011-12-25 15:38
zcs34989
Rank: 2
等 级:论坛游民
帖 子:34
专家分:34
注 册:2011-8-17
收藏
得分:0 
回复 2楼 embed_xuel
错误很多吗? 我都是按书上敲得啊  不知道怎么改  帮忙看看
还有一点书上的编译环境是Dev-c++,不知道跟这有没有关系

[fly]努力攻下C语言[/fly]
2011-12-25 15:46
zcs34989
Rank: 2
等 级:论坛游民
帖 子:34
专家分:34
注 册:2011-8-17
收藏
得分:0 
哎,没人帮忙解答啊。。。。。

[fly]努力攻下C语言[/fly]
2011-12-25 17:34
edward_eric
Rank: 2
等 级:论坛游民
帖 子:32
专家分:83
注 册:2011-10-5
收藏
得分:4 
嗯,文件打开模式错了,while 判断有问题。
2011-12-26 17:28
edward_eric
Rank: 2
等 级:论坛游民
帖 子:32
专家分:83
注 册:2011-10-5
收藏
得分:4 
还有就是变量声明放在复合语句最前面。
2011-12-26 17:32
zcs34989
Rank: 2
等 级:论坛游民
帖 子:34
专家分:34
注 册:2011-8-17
收藏
得分:0 
回复 6楼 edward_eric
谢啦,我再研究研究

[fly]努力攻下C语言[/fly]
2011-12-26 20:26
快速回复:编译文件操作时出现错误,帮忙看下原因,谢谢。。
数据加载中...
 
   



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

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