title: Program crashes when trying to access file, fstream --C++
body: <p>I am making a user database. When I try to open the <code>"dataBase.txt"</code> which holds all of the users and passwords, the console pops up (which should happen since it is a console application) but it says that the program has already complete. When I close it, my computer tell me that the program had crashed. The function is saved in a class. </p>
  
  <p>After some debugging the code seems to crash at <code>ifstream fin("dataBase.txt");</code></p>
  
  <p><strong>No error is returned from the compiler.</strong></p>
  
  <p><strong>The code for the function called is:</strong></p>
  
  <pre><code>void User_Psw::UserCheck()
  {
      // read from the database
      ifstream fin("dataBase.txt");
  
      while (!fin.eof())
      {
          fin &gt;&gt; Usernames[sizeOfDatabase] &gt;&gt; Password[sizeOfDatabase];
          sizeOfDatabase++; //The Number of lines in .txt
      }
  
      // rest of the program
      cout &lt;&lt; "Username: ";
      cin &gt;&gt; username;
  
      getNameIndex();
  
      cout &lt;&lt; "Password: ";
      cin &gt;&gt; password;
  
      if(!PasswordMatches())
      {
          cout &lt;&lt; "Access denied";
      }
  }
  </code></pre>
  
  <p><strong>I can add more code snippets if asked.</strong></p>