C语言文件编程题目(六)

阅读 58

2022-07-27


1.将A.txt文件中的内容复制到C.txt文件中

#include<stdio.h>
#include<stdlib.h>
int main() {
FILE *p1,*p2;
char ch;
p1 = fopen("E:\\A.txt","r");
if(!p1) {
printf("open file fail");
exit(0);
}
p2 = fopen("E:\\c.txt","w");
if(!p2) {
printf("open file fail");
exit(0);
}
while(!feof(p1)){
ch = fgetc(p1);
fputc(ch,p2);
}
fclose(p1);
fclose(p2);

}

 

精彩评论(0)

0 0 举报