如下这样可以了:
#include <stdio.h>
#include <stdlib.h>
void main()
{ FILE *fp1, *fp2;
int i=1;
char c;
if ((fp2=fopen("c:\\lhh\\f2.txt", "r"))==NULL)
{ printf("Can not open file!\n"); exit(0);}
if ((fp1=fopen("c:\\lhh\\f1.txt", "w"))==NULL)
{ printf("Can not open file!\n"); exit(0);}
while (i=1)
{ c=fgetc(fp2);
if (feof(fp2)) break;
fputc(c,fp1);
}
fclose(fp1);
fclose(fp2);
}
#include <stdio.h>
#include <stdlib.h>
void main()
{ FILE *fp1, *fp2;
int i=1;
char c;
if ((fp2=fopen("c:\\lhh\\f2.txt", "r"))==NULL)
{ printf("Can not open file!\n"); exit(0);}
if ((fp1=fopen("c:\\lhh\\f1.txt", "w"))==NULL)
{ printf("Can not open file!\n"); exit(0);}
while (i=1)
{ c=fgetc(fp2);
if (feof(fp2)) break;
fputc(c,fp1);
}
fclose(fp1);
fclose(fp2);
}