title: Copy only part of a binary file in C++
body: <p>This is a nice and intuitive way to copy files:</p>
  
  <pre><code>#include &lt;fstream&gt;
  
  int main()
  {
      std::ifstream  src("from.bn", std::ios::binary);
      std::ofstream  dst("to.bn",   std::ios::binary);
  
      dst &lt;&lt; src.rdbuf();
  }
  </code></pre>
  
  <p>How can one modify it in order to just copy the first <em>n</em> bytes of <code>src</code>?</p>