C盘中P1.c.txt文件的内容为:abcde。D盘中P1.c.txt为空文档。
#include<stdio.h>
#include<stdlib.h>
main()
{ FILE *f1,*f2;
int k;
if((f1=fopen("C:\\P1.c.txt","r"))==NULL)
{ printf("can not open file!\n");
exit(0);
}
if((f2=fopen("D:\\P1.c.txt","w"))==NULL)
{ printf("can not open file!\n");
exit(0);
}
for(k=1;k<500;k++)
{ if(feof(f1)) break;
fputc(fgetc(f1),f2);
}
printf("成功实现复制")
fclose(f1);
fclose(f2);
}