#include <stdio.h>
#include <stdlib.h>
main()
{
FILE *fp;
FILE *fpout;
char ch,*filename = "out.txt";
char *fina = "a.txt";
if( ( fp = fopen( filename ,"r" )) == NULL)
{
printf("cannot open file.\n");
exit(0);
}
if( ( fpout = fopen( fina, "w")) == NULL) //此处有错
{
printf("cannot open file.\n");
exit(0);
}
while ( ( ch = fgetc( fp )) != EOF)
{
fputc(ch,fpout);
}
fclose(fp);
}
if((fpout = fopen(fina,"w")) == NULL)
{
printf("cannot open file.\n");
}
直接copy过去试试。代码没问题!
LZ把没有用的空格去掉就可以了。
谢谢回答