#include "stdafx.h"#include "stdio.h"int main(int argc, char* argv[]){FILE*fp,*fp2;fp=fopen("D:\\C\\file5\\file.txt","r");fp2=fopen("D:\\C\\file5\\file2.txt","w");if(fp==NULL)printf("cannot open file");if(fp2==NULL)printf("cannot open file2");char ch;while(!feof(fp)){ch=fgetc(fp);putchar(ch);fputc(ch,fp2);}fclose(fp);fclose(fp2);return 0;}如果while循环里改为:while(!feof(fp)){putchar(fgetc(fp));fputc(fgetc(fp,fp2);}输出内容file的内容:abcdefghijklmnopqrstuvwxyz
- 2 回答
- 0 关注
- 62 浏览
添加回答
举报
0/150
提交
取消