title: Writing char* to binary file using ostream::write
body: <p>I am trying to write a char* to a binary file.</p>
  
  <p>This is what I have now.</p>
  
  <pre><code>void Write(char* fileName, char* pData)
  {
  
      ofstream binFile (fileName, ios::out | ios::binary);
      if (binFile.open())
      {
          binFile.write((char*)&amp;pData,         sizeof(pData));
          binFile.close();
      }
  }
  
  
  void Read(char* fileName, char* pData)
  {
      ifstream binFile(fileName, ios::in | ios::binary);
      if(binFile.open())
      {
          binFile.read(char*)&amp;pData, sizeof(pData));
          binFile.close
      }
  }
  
  int main()
  {
      char* testData = "ABCdEFG"; // not real data
      char* getTestData;
      char* file = "C:\\testData.dat";
      Write(file, testData);
      Read(file, getTestData);
  }
  </code></pre>
  
  <p>Test data will be of unknown length. May not always be the same. </p>
  
  <p>When i run the program once, and write and read. I can get back the test data.</p>
  
  <p>But when i stop the program and run it again, this time without writing. Just reading, i cannot get back the test data. </p>
  
  <p>I don't really understand whats happening here. 
  Can some one explain it to me? </p>