title: ifstream fileOpen causes program to 'terminate in an unusual way'
body: <p>At the line: <code>std::ifstream fileOpen(file.c_str());</code> in the below function the program crashes and gives me this error:</p>
  
  <blockquote>
    <p>This application has requested the Runtime to terminate it in an unusual way.
    Please contact the application's support team for more information.</p>
    
    <hr>
    
    <p>Process exited with return value 3</p>
  </blockquote>
  
  <p>However, in debug mode the whole program runs but at the return 0 statement for the main function I get</p>
  
  <blockquote>
    <p>Program received signal SIGTRAP, Trace/breakpoint trap.</p>
  </blockquote>
  
  <p>I am using Orwell Dev/C++ on Windows 7. From what I can gather the first problem is an exception that is thrown but not caught (I have not yet taught myself about exceptions so I have no idea what to do with this, but I can read up) and that it might be corrupting the stack. The latter error I can't get much specific information on. Could anyone please point me in the direction of a solution? Oh, also, the function is called three times before it crashes on the fourth. </p>
  
  <pre><code>//Get a line of data from a file
  std::string getData( std::string file, int line )
  {
      std::string data;
      std::ifstream fileOpen(file.c_str());
  
      if (fileOpen.is_open()) 
      {
          if( fileOpen.good() ) 
          {
              for( int lineno = 0; getline(fileOpen,data) &amp;&amp; lineno &lt; line; lineno ++ )
              {
                  if( lineno != line )
                  {
                      data = "";
                  }
              }
          }
  
          fileOpen.close();
      }
  
      return data;
  }
  
  //Parse comma delimited string into a vector
  void parseData( std::vector&lt;double&gt; &amp;temp, std::string data ) 
  {
      std::istringstream ss(data);
      std::string token;
  
      while(std::getline(ss, token, ',')) 
      {
          temp.push_back(atoi(token.c_str()));
      }
  }
  </code></pre>
  
  <p>These are called by code like this:</p>
  
  <pre><code>std::string instData = getData( levelName+".dat", 2 );
  
  if( instData != "" ) 
  {
      parseData( temp, instData );
      instances.resize(temp.size() / 4);
      j = 0;
  
      for( int i = 0; i &lt; temp.size(); i += 4 ) 
      {
          instances[ j ].type = temp[ i ];
          instances[ j ].xPos = temp[ i + 1 ];
          instances[ j ].yPos = temp[ i + 2 ];
          instances[ j ].zIndex = temp[ i + 3 ];
          j ++;
      }
  
      temp.clear();
  }
  </code></pre>
  
  <p>This code itself is part of a function that is designed to fill the various vectors with data from a specified file. The rest of the code in there is essentially the same as the above, though.</p>