标题:相同的代码,为什么vc6.0可运行,vs2010却不行呢?
取消只看楼主
starliyan
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-12-15
结帖率:0
已结贴  问题点数:10 回复次数:1 
相同的代码,为什么vc6.0可运行,vs2010却不行呢?
#include<stdio.h>
#include<stdlib.h>

void main()
{
    FILE *in, *out;
    char ch, infile[10],outfile[10];
    printf("please input the filename for reading:");
    scanf("%s",infile);

    printf("please input the filename for writing:");
    scanf("%s",outfile);

    if((in=fopen(infile,"r"))==NULL)
    {
        printf("open file(read) error!\n");
        exit(0);
    }

    if((out=fopen(outfile,"w"))==NULL)
    {
        printf("open file(write) error!\n");
        exit(0);
    }

    while(!feof(in))
    {
        ch=fgetc(in);
        fputc(ch,out);
        putchar(ch);
    }

    putchar(10);
    fclose(in);
    fclose(out);
}

问题:vs2010中,即使文件中有所要读入的文件,printf("open file(read) error!\n"),始终是open file(read) error!
vc6.0中却可以顺利执行。


[此贴子已经被作者于2016-5-27 15:36编辑过]

搜索更多相关主题的帖子: reading include writing please 
2016-05-27 14:43
starliyan
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2012-12-15
得分:0 
回复 2楼 rjsp
vs2010中,即使文件中有所要读入的文件,printf("open file(read) error!\n"),始终是open file(read) error!
vc6.0中却可以顺利执行。

另外,在两个软件中编译都没问题。
2016-05-27 15:36



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-465309-1-1.html




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

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