title: read the whole binary into a buffer then resolve it in specific format
body: <p>Here is my C++ homework. Given a binary file, this file consists of some data units. Every data unit contains two parts. The first part is 1 <code>char</code> and the second part is 1 <code>int</code>. Read the whole file into a buffer at a time and then extract all data units from the buffer.
  Now I've read the file into a buffer successfully like this:</p>
  
  <pre><code>char* readBinaryFile(const char* fileName) {
      ifstream file(fileName, ios::binary || ios::ate);
  
      // get the size of file
      streampos beg, end;
      beg = file.tellg();
      file.seekg(0,ios::end);
      end = file.tellg();
      long size = end - beg;
  
      char* buffer = new char[size];
  
      // now read the file into buffer
      file.seekg(0, ios::beg);
      file.read(buffer, size);
      file.close();
  
      return buffer;
  }
  </code></pre>
  
  <p>So my problem is how can I get the data unit from the buffer?</p>