正在加载图片...
#include "stdio. h main fp==NULL f FILE fpa, *fpb 表明文件不能正常打开 if ((fpa=fopen("d: tclladat",rD==NULL) i printf("cannot open file a dat! ) exit(0);) if(fpb=fopen(d: tclb. dat" ,"W))==NULL) i printf("cannot open file b dat! );exit(0);) while(! feof(fpa) e=fgetc(fpa) while c=EOF fputc(fgetc(fpa) fpb),I( fputc(C, fpb) if (fclose(fpa) c==fgetc(fpa):) i printf("cannot close file a dat! ) exit(O): if (fclose(fpb) fclose(印p)=0正常/1有错 i printf("cannot close file b dat! ) exit(O);J#include "stdio.h" main( ) { FILE *fpa, *fpb; if ((fpa=fopen("d:\\tc\\a.dat", "r"))= =NULL) { printf("cannot open file a.dat!"); exit(0); } if ((fpb=fopen("d:\\tc\\b.dat", "w"))= =NULL) { printf("cannot open file b.dat!"); exit(0); } while ( ! feof(fpa)) fputc(fgetc(fpa),fpb); if (fclose(fpa)) { printf("cannot close file a.dat!"); exit(0); } if (fclose(fpb)) { printf("cannot close file b.dat!"); exit(0); } } 当fpa指向文件末尾 时, feof(fpa) = =非零 fclose(fp) = 0 正常 / 1 有错 fp = =NULL, 表明文件不能正常打开 c=fgetc(fpa); while ( c!=EOF) { fputc(c, fpb); c=fgetc(fpa); }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有