#include#include #include void main(){FILE *fp1=NULL;FILE *fp2=NULL; char ch; int i=0; char str[6]="abcde"; char strl[1000]; fp1=fopen("1.txt","w"); if(fp1 == NULL) { perror(" open 1.txt"); //exit( EXIT_FAILURE ); } ch=getchar();fputc(ch,fp1);fputs(str,fp1);printf("%c",ch);fclose(fp1);fp1=fopen("1.txt","r");fp2=fopen("2.txt","w");// while(!feof(fp1)) while(fp1!='\0') will die for(i=0;i<7;i++) { ch=fgetc(fp1); fputc(ch,fp2); putchar(ch); } strl=fp1; // srtcpy(str,fp2); waring printf("%s\n",str);fclose(fp1);fclose(fp2);}
注:虚拟机实现 文件打开方式决定后续文件操作