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

}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章