相同的代码,为什么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编辑过]