title: ifstream vs. fread for binary files
body: <p>Which is faster? <code>ifstream</code> or <code>fread</code>.<br>
  Which should I use to read binary files?  </p>
  
  <p><code>fread()</code> puts the whole file into the memory.<br>
  So after <code>fread</code>, accessing the buffer it creates is fast.</p>
  
  <p>Does <code>ifstream::open()</code> puts the whole file into the memory?<br>
  or does it access the hard disk every time we run <code>ifstream::read()</code>?</p>
  
  <p>So... does <code>ifstream::open()</code> == <code>fread()</code>?<br>
  or (<code>ifstream::open(); ifstream::read(file_length);</code>) == <code>fread()</code>?</p>
  
  <p>Or shall I use <code>ifstream::rdbuf()-&gt;read()</code>?</p>
  
  <p><strong>edit:</strong>
  My readFile() method now looks something like this:</p>
  
  <pre><code>void readFile()
  {
      std::ifstream fin;
      fin.open("largefile.dat", ifstream::binary | ifstream::in);
      // in each of these small read methods, there are at least 1 fin.read()
      // call inside.
      readHeaderInfo(fin);
      readPreference(fin);
      readMainContent(fin);
      readVolumeData(fin);
      readTextureData(fin);
      fin.close();
  }
  </code></pre>
  
  <p>Will the multiple fin.read() calls in the small methods slow down the program?
  Shall I only use 1 fin.read() in the main method and pass the buffer into the small methods? I guess I am going to write a small program to test.</p>
  
  <p>Thanks!</p>