title: C++ Unhandled exception when reading file
body: <p>Trying to write .ply parser to use .ply models in OpenGL.</p>
  
  <p>Trying to begin to read the .ply file and write all the lines of it out. 
  My program does this but when it print out the last line i get Unhandled exception:</p>
  
  <blockquote>
    <p>Unhandled exception at 0x62aad540 (msvcr100d.dll) in PLY parser.exe: 0xC0000005: Access violation reading location 0x00000000.</p>
  </blockquote>
  
  <p>This is my code: </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  #include &lt;stdio.h&gt;
  
  
  using namespace std;
  
  
  int main ()
  {
      char buffer[10000];
      FILE * myFile;
      myFile = fopen("walkman.ply", "r");
      if(myFile != NULL)
      {
          while (!feof(myFile))
          {
  
                 cout&lt;&lt;fgets(buffer, 10000, myFile);
  
          }
          fclose(myFile);
      }
      else
      {
          cout&lt;&lt;"file not found"&lt;&lt;endl;
      }
  
      system("pause");
      return 0;
  }
  </code></pre>
  
  <p>This may be foolish error in my code, but it would be great if someone can spot the error causing this. </p>