[复制不正确]刚学文件
把file1的内容复制到file2文件里,但是file2的后尾多了一个ascii码为152的字符??file1.txt:i love u jat.
file2.txt:i love u jat.(句号后面多了一个值为152的字符)
该如何解决?
#include<stdio.h>
main()
{
FILE*in,*out;
char ch,infile[10],outfile[10];
printf("input infile name:\n");
scanf("%s",infile);
printf("input outfile name:\n");
scanf("%s",outfile);
if((in=fopen(infile,"r"))==NULL)
{
printf("cannot open infile\n");
exit(0);
}
if((out=fopen(outfile,"w"))==NULL)
{
printf("cannot open outfile\n");
exit(0);
}
while(!feof(in))
fputc(fgetc(in),out);
fclose(in);
fclose(out);
getch();
}