正在加载图片...
93文件的读写 例91用依次读取字符的方式,将 source.tx文件的内容复制到 destination. txt文件中。 void mainO FILE*fpl, "fp2; charch if(fpl=fopen("C: source. txt","r==NULL i printf( " File could not be opened! n); exit(0) if(fp2=fopen(C: destination. txt", W=NULL i printf("File could not be opened! n); t(0);} while((ch=fgetc(pl)=EoF) fputc(ch, fp2); fclose(fpl); fclose(fp2) ☆☆第牙章文件操作 21☆☆ 第9章 文件操作 21 例 9-1 用依次读取字符的方式,将source.txt文件的内容复制到 destination.txt文件中。 9.3 文件的读写 void main() { FILE *fp1,*fp2; char ch; if((fp1=fopen("C:\\source.txt","r"))==NULL) { printf("File could not be opened!\n"); exit(0); } if((fp2=fopen("C:\\destination.txt","w"))==NULL) { printf("File could not be opened!\n"); exit(0); } while((ch=fgetc(fp1))!=EOF) fputc(ch,fp2); fclose(fp1); fclose(fp2); }
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有