title: Fastest way to read a pipe from C/C++ program?
body: <p>If I want to pipe bytes of data in to a C/C++ program on Linux like this:</p>
  
  <blockquote>
    <p>cat my_file | ./my_app</p>
  </blockquote>
  
  <p>but:</p>
  
  <ol>
  <li>We cannot assume the piped data is going to originate from a file</li>
  <li>We wish to interpret the data as bytes in the file (as opposed to strings)</li>
  </ol>
  
  <p>what would be the fastest technique to read the pipe from the C/C++ application? </p>
  
  <p>I have done a little research and found:</p>
  
  <ul>
  <li><code>read()</code></li>
  <li><code>std::cin.read()</code></li>
  <li><code>popen()</code> </li>
  </ul>
  
  <p>but I am not sure if there is a better way, or which of the above would be better.</p>
  
  <p>EDIT: There <strong>is</strong> a performance requirement on this, hence why I am asking for the technique with the smallest overhead.</p>