#include<stdio.h>
#include<stdlib.h>
int main()
{
FILE *fp;
FILE *fp1;
char ch;
char ch1;
if((fp=fopen("file1.txt","w"))==NULL)
{
printf("cannot open this file!\n");
exit(0);
}
while((ch=getchar())!='\n')
fputc(ch,fp);
fclose(fp);
/*if((fp=fopen("file1.txt","r"))==NULL)
{
printf("cannot open this file!\n");
exit(0);
}
while((ch=fgetc(fp))!=EOF)
putchar(ch);
fclose(fp);*/
if((fp1=fopen("file2.txt","w"))==NULL)
{
printf("cannot open this file2!\n");
exit(0);
}
while((ch1=getchar())!='\n')
fputc(ch1,fp1);
fclose(fp1);
/*if((fp1=fopen("file2.txt","r"))==NULL)
{
printf("cannot open this file2!\n");
exit(0);
}
while((ch1=fgetc(fp))!=EOF)
putchar(ch1);
fclose(fp1);*/
return 0;
}
相关分类