69,371
社区成员
发帖
与我相关
我的任务
分享
#include <stdio.h>
#include <stdlib.h>
void main()
{
FILE *in,*out;
char inname[10],outname[10];
char ch;
printf("Put infile name:\n");
scanf("%s",inname);
printf("Put outfile name\n");
scanf("%s",outname);
if ((in=fopen(inname,"r"))==NULL)
{
printf("There is no existing %s\n",inname);
exit(0);
}
if ((out=fopen(outname,"w"))==NULL)
{
printf("NO existing file,then creat\n");
if ((out=fopen(outname,"w+"))==NULL)
{
printf("Error\n");
exit(0);
}
}
while(!feof(in))
{ch=fgetc(in);
fputc(ch,out);
putchar(ch);
}
fclose(in);
fclose(out);
}
while(1)
{ch=fgetc(in);
if(feof(in)) break;
fputc(ch,out);
putchar(ch);
}