#include <stdio.h>
#include <stdlib.h>
int main () {
FILE *a ,*b;
char ch, filename_a[20], filename_b[20];
printf("输入写入(新建)a的文件名:");
scanf("%s",filename_a);
printf("输入写入(新建)b的文件名:");
scanf("%s",filename_b);
if ((a = fopen(filename_a, "w")) == NULL)
{
printf("NULL");
exit(0);
}
if ((b = fopen(filename_b , "w")) == NULL)
{
printf("NULL");
exit(0);
}
ch = getchar();
printf("请输入你想要存在文件中的句子,以“回车键结束”结束\n");
ch = getchar();
while ( ch != '\n')
{
fputc(ch,a);
putchar(ch);
ch = getchar();
}
ch = getchar();
printf("\n");
ch = fgetc(a);
while ( !feof(a) )
{
fputc(ch,b);
putchar(ch);
ch = fgetc(a);
}
putchar(10);
fclose(a);
fclose(b);
return 0;
}