字符串的读写函数(fgets和fputs)

#include
#include
main(){
FILE *fp1,*fp2;
char file1[20],file2[20],s[10];
if((fp1=fopen("D:\\Test.txt","r"))==NULL)
{
printf("file1 open error.\n");
exit(0);
}
if((fp2=fopen("D:\\Test2.txt","w"))==NULL){
printf("file2 open error.\n");
exit(0);
}
while(fgets(s,10,fp1)!=NULL)
fputs(s,fp2);
fclose(fp1);
fclose(fp2);


}

你可能感兴趣的:(C语言)