- 论坛徽章:
- 0
|
最近在看谭浩强的C程序入门书,书上一道关于文件拷贝的例题源码如下:
#include<stdio.h>
main(int argc,char *argv[])
{FILE *in,*out;
char ch;
if(argc!=3)
{printf("You forgot to enter a filemane\n");
exit(0);
}
if((in=fopen(argv[1],"r"))==NULL)
{printf("cannot open infile\n");
exit(0);
}
if((out=fopen(argv[2],"w"))==NULL)
{printf("cannot open outfile\n");
exit(0);
}
while(!feof(in)) fputc(fgetc(in),out);
fclose(in);
fclose(out);
system("pause");
}
在windows的cmd中输入
E:\>ctry 1.txt 2.txt
理论上应该是1.txt的内容拷进2.txt中,但发现在2.txt中多了一个特殊字符,请问是什么原因造成的?
用的是dev-c++。
|
|