How do i link up the password check before it run mainmenu?

could someone kindly help me on my userid login n password?
i can link it up? Which part of my code when wrong?

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <cstdio>
#include <ctime>
#include <cmath>
using namespace std;

void mainmenu(int num);

int main(int num)
{
// User has three trys to login with the correct password until they are shut off
int wrongpasswordCount = 3;
// User has five trys to login with a correct username and password until they are shut off
int wrongsusernamepasswordCount = 5;
bool loopStatus = true;
while (wrongpasswordCount != 0 && wrongsusernamepasswordCount != 0 && loopStatus == true)
{
cout << "Username: ";
string username;
cin >> username;
cout << "Password: ";
string password;
cin >> password;

string correctusername ="Jacky";
string correctpassword ="12345";


if (username==correctusername && password==correctpassword)
{
loopStatus = false;
cout << "\nWelcome, " << username << "! ";

bool loopCommand = true;
while (loopCommand == true)
{
mainmenu(0);
} //end bool loopCommand while

}
else
{

if (username==correctusername && password!=correctpassword)
{ wrongpasswordCount -= 1;
cout<<"Password is incorrect, " << wrongpasswordCount << " attempts left.\n"; }

else { wrongsusernamepasswordCount -= 1;
cout << "Username and/or password are incorect, "<< wrongsusernamepasswordCount <<" attempts left.\n"; }

}
}
return 0;
}

void mainmenu(int num);
{
char choice;

cout << "Enter 1, 2, 3 or 4: ";
cin >> choice;

switch (choice)
{
case '1': cout << "You have entered Cashier Module.\n";
{
// Call displayValue with argument 5
cout << "Now I am back in main.\n";
}

break;
case '2': cout << "You have entered Inventory Database Module.\n";
break;
case '3': cout << "You have entered Report Module.\n";
break;
case '4': cout << "You have entered Exit.\n";
break;
default: cout << "You did not enter 1, 2, 3, or 4!\n";
}
return 0;
}
Topic archived. No new replies allowed.