解题思路:用字符输入输出函数fgetc()、fputc()或字符串输入输出函数fgets()、fputs()均可。
程序运行结果示例:
疏影横斜水清浅,暗香浮动月黄昏。
#include <stdio.h>
int main()
{
char c;
FILE *fp1, *fp2;
fp1 = fopen("file1.dat", "r");
fp2 = fopen("file2.dat", "w+");
while(!feof(fp1)) {
c = fgetc(fp1);
putchar(c);
fputc(c, fp2);
}
fclose(fp1);
fclose(fp2);
return 0;
}