#include "stdio.h"#include "string.h"void main(){ FILE *fp,*fp1; char str[200]; if((fp=fopen("new.txt","wt"))==NULL) /* 假设新旧文本文件分别是new.txt,old.txt */ { printf("cannot open file\n"); return; } if((fp1=fopen("old.txt","rt"))==NULL) { printf("cannot open file\n"); return; } while (fgets(str,200,fp1)) //读取一行,并判断文件是否结束 { fprintf(fp,"%s",str); } fclose(fp1); fclose(fp);}