文件,在操作台上进行自主文件拷贝,并进行自主命名。
#include<stdio.h>
#include<stdlib.h>
int main()
{
FILE *infp,*outfp;
char ch;char a[128],b[128];
printf("请输入本文件目录中存在的文件名加后缀:");
gets(a);//infile.txt
printf("请输入输出文件名加后缀:");
gets(b);
if((infp=fopen(a,"r"))==NULL)
{
printf("cannot open %s\n",a);
exit(0);
}
if((outfp=fopen(b,"w"))==NULL)//outfile.txt
{
printf("cannot open out %s \n",b);
exit(0);
}
#if 0
#else
while(1)
{
ch=fgetc(infp);
if(ch==EOF)
break;
fputc(ch,outfp);
}
#endif
fclose(infp);
fclose(outfp);
printf("复制成功\n");
}