feof()为什么不能正确执行,他执行的机理是什么?程序如下
#include <iostream.h>
#include <stdio.h>
#include <process.h>
void main(int argc,char * argv[])
{
FILE * fin,*fout;
//check correctness of arguments
if(argc != 3)
{
printf("Arguments error\n");
exit(-1);
}
//open source file
if((fin=fopen(argv[1],"r"))==NULL)
{
printf("Can't open %s\n",argv[1]);
exit(-1);
}
//open object file
if((fout=fopen(argv[2],"w"))==NULL)
{
printf("Can's open %s\n",argv[2]);
exit(-1);
}
//copy file
while(!feof(fin))
putc(getc(fin),fout);
//close files
fclose(fin);
fclose(fout);
}
执行结果是:目标文件比原文件一个字节,十六制FF
这是为什么?请帮我详细解释一下。