如何在此下,补充?以达到目的?
#include "stdio.h"
main ()
{FILE *in,*out;
char ch,infile[10],outfile[10];
printf ("Enter the infile name:\n");
scanf ("%s",infile);
printf ("Enter the outfile name:\n");
scanf("%s",outfile);
if((in=fopen (infile,"r"))==NULL)
{ printf("cannot open infile\n");
exit(0);
}
if ((out=fopen (outfile,"w"))==NULL)
{printf ("cannot open outfile\n");
exit(0);
}
while(!feof(in))fputc(fgetc(in),out);
fclose(in);
fclose(out);
}
该在哪里补充,if之前还是while之后
该在哪里补充,if之前还是while之后
追答在fclose(out);之后,因为要防止文件丢失
我说清楚点:
其实这个功能没必要这么麻烦来实现的。只需要使用DOS或Linux命令就能实现的。
完整伪程序:
#include <stdlib.h>之所以使用命令是因为C语言里面好像没有创建文件夹的函数,如果非要使用就只能调用API了。