title: Segmentation fault when reading binary file
body: <p>I am trying to read data from an existing binary file, but all I got is a segmentation fault.
  I thought that it might be come from the struct, so I used a temporary array where I try to fill in the values, but the problem seems to come from the ifstream read function. Can anybody help me to solve this problem?</p>
  
  <pre><code>bool RestoreRaspberry::RestorePhysicalAdress(TAddressHolder &amp;address) {
      mPRINT("now i am in restore physical address\n");
      /*
      if (!OpenFileForRead(infile, FILENAME_PHYSICALADDRESS)){
          printf("\nRestoreUnit: Error open file Restore Physical Address\n");
          return false;
      }
      */
      ifstream ifile;
      ifile.open(FILENAME_PHYSICALADDRESS, ios_base::binary | ios_base::in);
      if (!ifile.is_open())
      {
          printf("\nRestoreUnit: Error open file Restore Physical Address\n");
          return false;
      }
  
      printf("\nRestoreUnit: now trying to read it into adress structure\n");
  
      uint8 arr[3];
      //the problem occurs right here
      for (int i = 0; i &lt; cMAX_ADRESS_SIZE || !ifile.eof(); i++) {
          ifile.read(reinterpret_cast&lt;char *&gt;(arr[i]), sizeof(uint8)); 
      }
  
  #ifdef DEBUG
      printf("physical address from restoring unit: ");
      /*
      printf("%#x ", address.Address[0]);
      printf("%#x ", address.Address[1]);
      printf("%#x \n", address.Address[2]);
      */
      printf("%#x", arr[0]);
      printf("%#x ", arr[1]);
      printf("%#x \n", arr[2]);
  #endif
  ifile.close();
      if (!ifile){//!CloseFileStream(infile)){
          printf("\nRestoreUnit: Error close file Restore Physical Address\n");
          return false;
      }
  
  } 
  </code></pre>