Bank Login System
<p>Well what I'm trying to do is create a login system for my banking script. WHat happens is the ID identification works, but when it comes to confirming your password, it is all messed up... can someone help me out? (I'm talking about the login() function specifically).</p>

<pre><code>#include "stdafx.h"
#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;string.h&gt;
#include &lt;fstream&gt;
#include &lt;Windows.h&gt;
#include &lt;conio.h&gt;
using namespace std;
bool loop = true;

class account
{
          int id;
         char name[40];
         char password[40];
public:
          void getData()
          {
                     cout &lt;&lt; "\nEnter your name: ";
                     cin &gt;&gt; name;
                     cout &lt;&lt; "\nEnter ID: ";
                     cin &gt;&gt; id;
                     cout &lt;&lt; "\Enter pass: ";
                     cin &gt;&gt; password;
          }
          void showData()
          {
                     cout &lt;&lt; "\nName: ";
                     puts(name);
                     cout &lt;&lt; "\nID: " &lt;&lt; id;
                     cout &lt;&lt; "\n";
          }
          int returnId()
          {
              return id;
          }
          char* returnPassword()
          {
              return password;
          }
};

void createAccount()
{
    account obj;
    ofstream fileCreate;
    fileCreate.open("accounts.dat", ios::binary|ios::app);
    obj.getData();
    fileCreate.write((char*)&amp;obj,sizeof(obj));
    fileCreate.close();
}

void display()
{
    account obj;
    ifstream fileRead;
    fileRead.open("accounts.dat", ios::binary);
    while(fileRead.read((char*)&amp;obj, sizeof(obj)))
    {
        obj.showData();
    }
    fileRead.close();
}

void search(int n)
{
    account obj;
    ifstream fileRead;
    bool found = false;
    fileRead.open("accounts.dat", ios::binary);
    while(fileRead.read((char *) &amp;obj, sizeof(obj)) &amp;&amp; found == false)
    {
        if(obj.returnId() == n)
        {
            system("CLS");
            cout &lt;&lt; "Search for ID " &lt;&lt; n &lt;&lt; " found.";
            cout &lt;&lt; "\n------------------------------------------------";
            obj.showData();
            cout &lt;&lt; "------------------------------------------------\n";
            cout &lt;&lt; "\n\n";
            found = true;
        }
    }
    if (found == false) {cout &lt;&lt; "The user can not be found.\n\n";}
    fileRead.close();
}

void login(int inputId, char* inputPassword)
{
    account obj;
    ifstream fileRead;
    fileRead.open("accounts.dat", ios::binary);
    while(fileRead.read((char *) &amp;obj, sizeof(obj)))
    {
        if (obj.returnId() == inputId &amp;&amp; obj.returnPassword() == inputPassword)
        {
            cout &lt;&lt; "You logged in.. yay.";
        }
        else {
            cout &lt;&lt; "Incorrect ID or password.";
        }
    }
}









void main()
{
    cout &lt;&lt; "Welcome to LZ Bank of the World.\n\n";

    while (loop==true)
    {
        char choice[10];
        cout &lt;&lt; "Please select an option:\n";
        cout &lt;&lt; "------------------------------------------------\n";
        cout &lt;&lt; "(a)Log into an account\n(b)Create an account\n(s)Search an account\n(e)Exit\n";
        cout &lt;&lt; "------------------------------------------------\n";
        cout &lt;&lt; "Choice: ";
        cin &gt;&gt; choice;
        choice[0] = tolower(choice[0]);
        cout &lt;&lt; "\n------------------------------------------------\n\n";

        switch (choice[0])
        {
        case 'a':
            int inputId;
            char inputPassword[40];
            system("cls");
            cout &lt;&lt; "ID: ";
            cin &gt;&gt; inputId;
            cout &lt;&lt; "\nPassword: ";
            cin &gt;&gt; inputPassword;
            login(inputId, inputPassword);
            break;
        case 'w':
            display();
            break;
        case 's':
            int n;
            cout &lt;&lt; "Enter the ID of the account: ";
            cin &gt;&gt; n;
            search(n);
            break;
        case 'b':
            createAccount();
            break;
        case 'e':
            loop = false;
            break;
        default:
            system("CLS");
            cout &lt;&lt; "The option \"" &lt;&lt; choice[0] &lt;&lt;  "\" is invalid.\n\n\n\n";
            break;
        }

    };
    cout &lt;&lt; "\n\n\n";
    cout &lt;&lt; "Click anything to exit.";
    getch();
}
</code></pre>
