title: C++ reading binary files
body: <p>I want to understand how does reading binary files work in C++. 
  My code:</p>
  
  <pre><code>int main() {
      ifstream ifd("input.png",ios::binary |ios::ate);
      int size = ifd.tellg();
      ifd.seekg(0,  ios::beg);
      vector&lt;char&gt; buffer;
      buffer.reserve(size);
      ifd.read(buffer.data(), size);
  
      cout &lt;&lt; buffer.data();
      return 0;
  }
  </code></pre>
  
  <p>I thought that if I cout my buffer I would get the result in binary but that is not the case.</p>
  
  <p><strong><code>My output is: ˙Ř˙á6Exif</code></strong> </p>
  
  <p>And if I read the text file it displays the text in normal form not in binary. Obviously my logic is not right here.
  How can I read files to a buffer so it will contain binary values? 
  P.s. I`m doing this for implementing a Shannon-Fano algorithm so if anyone has any advice on reading a binary file I would be grateful.</p>