cs162/assignments/assignment1/magic.cpp
/*********************************************************************
 * ** Function: check_login
 * ** Description: This function checks the credentials given by the user against all of the credentials in the wizard.txt file
 * ** Parameters: int login_id, string password, wizard *wiz, int num_wizards, int &wiz_index
 * ** Pre-Conditions: valid credentials are given and wiz array is full of correct wizards
 * ** Post-Conditions: user logged in or not
 * *********************************************************************/
check_login
Description: This function checks the credentials given by the user against all of the credentials in the wizard.txt file
Parameters: int login_id, string password, wizard *wiz, int num_wizards, int &wiz_index
Pre-Conditions: valid credentials are given and wiz array is full of correct wizards
Post-Conditions: user logged in or not
check_login Description : This function checks the credentials given by the user against all of the credentials in the wizard . txt file Parameters : int login_id string password wizard * wiz int num_wizards int &wiz_index Pre - Conditions : valid credentials are given and wiz array is full of correct wizards Post - Conditions : user logged in or not
void check_login(int login_id, string password, wizard *wiz, int num_wizards, int &wiz_index) {
	bool logged_in = false;
	for(int i = 0; i < num_wizards; i++) {
		if(login_id == wiz[i].id && password == wiz[i].password) {
			cout << "You have successfully logged in!" << endl;
			logged_in = true;
			wiz_index = i;
			break;
		}
	}
	if(logged_in == false) {
		cout << "Password or Login ID incorrect!" << endl;
		login_details(login_id, password);
		check_login(login_id, password, wiz, num_wizards, wiz_index);
	}
}
void check_login ( int login_id , string password , wizard * wiz , int num_wizards , int & wiz_index ) { bool logged_in = false ; for ( int i = 0 ; i < num_wizards ; i ++ ) { if ( login_id == wiz [ i ] . id && password == wiz [ i ] . password ) { cout << " " << endl ; logged_in = true ; wiz_index = i ; break ; } } if ( logged_in == false ) { cout << " " << endl ; login_details ( login_id , password ) ; check_login ( login_id , password , wiz , num_wizards , wiz_index ) ; } }
** Function: check_login
 ** Description: This function checks the credentials given by the user against all of the credentials in the wizard.txt file
 ** Parameters: int login_id, string password, wizard *wiz, int num_wizards, int &wiz_index
 ** Pre-Conditions: valid credentials are given and wiz array is full of correct wizards
 ** Post-Conditions: user logged in or not
** Function : check_login ** Description : This function checks the credentials given by the user against all of the credentials in the wizard . txt file ** Parameters : int login_id string password wizard * wiz int num_wizards int &wiz_index ** Pre - Conditions : valid credentials are given and wiz array is full of correct wizards ** Post - Conditions : user logged in or not