title: C++ Program Crashes when method return value is assigned to an int
body: <p>This problem is blowing my mind right now.</p>
  
  <pre><code>int main()
  {
      char inputChar;
      char *buffer = nullptr;
      int size = 0;
  
      read(buffer);  //this is the line causing problems...
  
      int numberOfFrames = (size / MAX_FRAME_SIZE) + 1;
      frame array[numberOfFrames];
  
      for(int i = 0; i &lt; size; i++)
      {
          buffer[i] = appendParityBit(buffer[i]);
      }
  
      constructFrame(buffer, size, array);
      transmitFrames(array, numberOfFrames);
  } 
  
  int read(char *buffer)
  {
      int fileSize;
      ifstream myfile ("inputFile");
      if (myfile.is_open())
      {
          fileSize = getFileLength(myfile); 
          buffer = new char[fileSize];
  
          myfile.read(buffer, fileSize);
          myfile.close();
      }
      return fileSize;
  }
  
  int getFileLength(ifstream &amp;myfile)
  {
      myfile.seekg(0, ios::end);
      int size = (int) myfile.tellg() - 1;
      myfile.seekg(0, ios::beg);
      return size;
  }
  </code></pre>
  
  <p>now if i do a </p>
  
  <pre><code>cout &lt;&lt; read(buffer); 
  </code></pre>
  
  <p>on the line that is causing problems, i receive an integer back...great, perfect.  but if i try to do </p>
  
  <pre><code>size = read(buffer);  
  </code></pre>
  
  <p>my program crashes...i'm at a loss.</p>