FILE*One= fopen("1.txt", "rb"); // указывает на 1.txt i=0; while(!feof(One)){ if(i<a||i>number){ fin_1.getline(buff,30); fout_2<<buff<<endl; } else{ fin_3.getline(buff,30); fout_2<<buff<<endl; } i++; } 
  • one
    Because you are reading from one stream ( fin_1 ), and on reaching the end you check another ( One ). - ߊߚߤߘ
  • and how to make the cycle all the same ended. How to make one of these threads? - The razor of reason
  • как из этих потоков сделать один - choose one of these two streams and work only with it. The second one is removed as extra. - ߊߚߤߘ
  • close to heading question: Read lines from a file while they are - jfs
  • Related question: Proper use of end-of-file checking - ߊߚߤߘ

1 answer 1

Although you are told that you are reading one file and checking another ... in any case, checking

 while(!feof(file)) { ... } 

incorrect, because the end of file attribute is set only after an unsuccessful attempt to read past the end of the file .

  • when feof makes sense to cause looks like a frequent question. Perhaps it makes sense in one place popular with examples to present, and other questions to close as duplicates. - jfs
  • @jfs has I once wrote such a question-answer, such an array of critics flew in that I thought it would be best to remove it and promised myself that I would not do this anymore. Today I make another (if it does not work out - certainly the last one ....) attempt. - Harry
  • It is worth remembering that the rules for questions / answers remain the same, regardless of who is the author. What is the procedure for creating canonical questions? . Problems can, of course, arise from scratch. In such cases, you can discuss a specific example on Mete. - jfs