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

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);

}
原创文章 217 获赞 634 访问量 50万+

猜你喜欢

转载自blog.csdn.net/wyf2017/article/details/105507945