title: Reading Binary Files into an array of ints c++
body: <p>I have a method which writes a binary file from an <code>int</code> array. (it could be wrong too)</p>
  
  <pre><code>void bcdEncoder::writeBinaryFile(unsigned int packedBcdArray[], int size)
  {
      fstream binaryIo;
      binaryIo.open("PridePrejudice.bin", ios::out| ios::binary | ios::trunc);
      binaryIo.seekp(0);
      binaryIo.write((char*)packedBcdArray, size * sizeof(packedBcdArray[0]));
      binaryIo.seekp(0);
  
      binaryIo.close();
  }
  </code></pre>
  
  <p>I need to now read that binary file back. And preferably have it read it back into another array of <code>unsigned int</code>s without any information loss.</p>
  
  <p>I have something like the following code, but I have no idea on how reading binary files really works, and no idea how to read it into an array of <code>int</code>s.</p>
  
  <pre><code>void bcdEncoder::readBinaryFile(string fileName)
  {
      // myArray = my dnynamic int array
  
      fstream binaryIo;
      binaryIo.open(fileName, ios::in | ios::binary | ios::trunc);
  
      binaryIo.seekp(0);
  
      binaryIo.seekg(0);
      binaryIo.read((int*)myArray, size * sizeof(myFile));
  
      binaryIo.close();
  }
  </code></pre>
  
  <h2>Question:</h2>
  
  <p>How to complete the implementation of the function that reads binary files?</p>