title: C++ fstream - Account login/registration via txt file
body: <p>I'm new to c++ and trying to create an account manager to handle:
  log, register, change pass, etc.</p>
  
  <p>I'm having difficulties with comparing user input for username and password:</p>
  
  <p>EDIT:
  My problem is that getline(openFile, tempUser, ';'); doesnt go to the next line after semi-colon.</p>
  
  <p>So if I have USERNAME;PASSWORD, it checks username and password as if they are account names.</p>
  
  <p>This is my LOGIN function:</p>
  
  <pre><code>void AccountManager::login(AccountManager &amp;account){
    string username, password, tempUser, tempPass;
    int wrongUser(0);
    fstream openFile("UserPass.txt", ios::out | ios::in | ios::app);
    if(openFile.good()){
      do{
        cout &lt;&lt; "Type in your username: " &lt;&lt; endl;
        getline(cin, username);
        cin.sync();
        cout &lt;&lt; "Type in your password: " &lt;&lt; endl;
        getline(cin, password);
        cin.sync();
        while(!openFile.eof()){
          getline(openFile, tempUser, ';');
          if(tempUser == username){
            getline(openFile.ignore(tempUser.length()+1),tempPass);
            if(tempPass == password){
              wrongUser = 1;
              cout &lt;&lt; "Thank you for logging in. " &lt;&lt; endl;
              switchLog(account);
            }else{
              cout &lt;&lt; "Wrong username or password, please try again." &lt;&lt; endl; ;
              break;
            }
          }
        };
      }while(wrongUser = 0); // &lt;&lt;&lt; while loop not working
    }
    else{ //cant Open file - error handling
      if( account.UserPass[username] == password){
        switchLog(account);
      }
      else{
        cout &lt;&lt; "The username and password do not match. ";
      }
      cerr &lt;&lt; "Error accessing data!" &lt;&lt;endl;
      exit(1);
    }
    openFile.close();
  }
  </code></pre>