How to store Username and Password into a file in 2 void functions?
<p>I'm going to simplify my question... How would I implement an If/else statement or any statement that would take data the user enters from my createaccount function and verifies it against the login function? If the login does not match what is in the file "accounts.txt", it would not work and loops back to the mainmenu function.</p>

<pre><code> using namespace std;

    char mainMenu();
    void createAccount();
    void login();
    char bankingMenu();                 // Prototypes Declared Here
    void deposit();
    void withdraw();
    void displayBalance();
    void ShowTransHist(); // Gets transaction history from the file path string and display
int main()
{


    char choice;
    while (choice != 'q' || choice != 'Q')
    {
        choice = mainMenu();
        if (choice == 'q' || choice == 'Q') break;
        switch (choice)
        {
        case 'l':
        case 'L':
            login();
            break;
        case 'c':
        case 'C':
            createAccount();
            break;
        case 'v':
        case 'V':
            cout &lt;&lt; "Thank you for using our bank and Future Computer Programmer ATM Machine! \nFor your continued support, we are offering 3% cash back on all debit purchases." &lt;&lt; endl;

        }
    }
    return 0;
}
char mainMenu() // Function to display the main menu, not banking menu
{
    char choice;
    cout &lt;&lt; "Please select an option from the menu below:" &lt;&lt; endl;
    cout &lt;&lt; "l -&gt; Login" &lt;&lt; endl;
    cout &lt;&lt; "c -&gt; Create New Account" &lt;&lt; endl;
    cout &lt;&lt; "v -&gt; View Promotions" &lt;&lt; endl;
    cout &lt;&lt; "q -&gt; Quit" &lt;&lt; endl;
    cout &lt;&lt; "Enter your choice: " &lt;&lt; endl;
    cin &gt;&gt; choice;
    return choice;

}
void createAccount() // Takes and stores users login information, username and password
{
   string username;
   string password;
   cout &lt;&lt; "Please create a username";
   cin &gt;&gt; username;
   cout &lt;&lt; "Please create a password";
   cin &gt;&gt; password;
   ofstream createaccount;
   createaccount.open("accounts.txt");
   createaccount &lt;&lt; username &lt;&lt; " " &lt;&lt; password;
   createaccount.close();
   cout &lt;&lt; "Information saved" &lt;&lt; endl;

}
void login() // Takes information stored in create account
{
    string username;
    string password;
    cout &lt;&lt; "Please enter your username";
    cin &gt;&gt; username;
    cout &lt;&lt; "Please enter your password";
    cin &gt;&gt; password;
    ifstream savedaccount;
    savedaccount.open("accounts.txt");
    savedaccount &gt;&gt; username &gt;&gt; password;
    savedaccount.close();
    cout &lt;&lt; "Login successful";

}
</code></pre>