title: c++ how to copy specific lines from a file to another?
body: <p>I want to write a program that will copy a few lines in a file in another file. for example copy line 5 to 100 from file a and write it to file b. thanks</p>
  
  <p>this is my code.but my code copying all content of file a to file b.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  using namespace std;
  
  int main(){
     char line[100];
  
     ifstream is("a.txt");
     ofstream os("b.txt");
  
     if (is.is_open()){
        while (!is.eof()){
           is.getline(line,100,'\n');
           os &lt;&lt; line &lt;&lt; endl;
           }
     }
     else{
        cout &lt;&lt; "a.txt couldn't be opened. Creat and write something in a.txt, and try again." &lt;&lt; endl;
     }
  
     return 0;
  }
  </code></pre>