how to separate login for admin and user? c++

How to compare the username and password entered by user with the data(username and password saved in before) in the admin array and customer array,

so for example when it match the username and password in the admin array, it will directs the user to the admin_mainmenu(), otherwise it directs to the customer_mainmenu().

help please..


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include <fstream>
#include <string>
using namespace std;


char username_admin[10];
char password_admin[10];

string username_customer[50];
string password_customer[50];


int main(){
fstream login("password.txt", ios_base::out | ios_base::in);  // will not create file
if (login.is_open())
{
    cout << "Database exists." << endl;
    admin_signin();
}
else
{
    cout << "Database Do not exits. Be an adminstrator. Sign Up";
    admin_signup();
    login.clear();
    login.open("password.txt", ios_base::out);  // will create if necessary
}

    admin/customer_mainmenu();


    system("pause");
return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
if (login.is_open())
{
    cout << "Database exists." << endl;
    if (!admin_signin()) // couldn't login with admin credentials
        customer_mainmenu()
}
else
{
    cout << "Database Do not exits. Be an adminstrator. Sign Up";
    admin_signup();
    login.clear();
    login.open("password.txt", ios_base::out);  // will create if necessary
}

admin_mainmenu();
Topic archived. No new replies allowed.