cs162/assignments/assignment1/magic.cpp
/*********************************************************************
 * ** Function: create_wiz
 * ** Description: This function creates the array full of all of the wizards given in the wizards.txt file
 * ** Parameters: string file1, int &num_wizards
 * ** Pre-Conditions: Correct wizards.txt file is given in correct format
 * ** Post-Conditions: wiz is filled with wizards
 * *********************************************************************/
create_wiz
Description: This function creates the array full of all of the wizards given in the wizards.txt file
Parameters: string file1, int #_wizards
Pre-Conditions: Correct wizards.txt file is given in correct format
Post-Conditions: wiz is filled with wizards
create_wiz Description : This function creates the array full of all of the wizards given in the wizards . txt file Parameters : string file1 int #_wizards Pre - Conditions : Correct wizards . txt file is given in correct format Post - Conditions : wiz is filled with wizards
wizard * create_wiz(string file1, int &num_wizards) {
	string num_w;
	ifstream f1;
	do {
		f1.open(file1.c_str(), ios::in);
	} while(!f1.is_open());
	getline(f1, num_w);
	num_wizards = atoi(num_w.c_str());
	wizard *wiz = new wizard[num_wizards];
	for(int i = 0; i < num_wizards; i++) {
		f1 >> wiz[i].name >> wiz[i].id >> wiz[i].password >> wiz[i].position_title >> wiz[i].beard_length;
	}
	f1.close();
	return wiz;
}
wizard * create_wiz ( string file1 , int & num_wizards ) { string num_w ; ifstream f1 ; do { f1 . open ( file1 . c_str ( ) , ios :: in ) ; } while ( ! f1 . is_open ( ) ) ; getline ( f1 , num_w ) ; num_wizards = atoi ( num_w . c_str ( ) ) ; wizard * wiz = new wizard [ num_wizards ] ; for ( int i = 0 ; i < num_wizards ; i ++ ) { f1 >> wiz [ i ] . name >> wiz [ i ] . id >> wiz [ i ] . password >> wiz [ i ] . position_title >> wiz [ i ] . beard_length ; } f1 . close ( ) ; return wiz ; }
** Function: create_wiz
 ** Description: This function creates the array full of all of the wizards given in the wizards.txt file
 ** Parameters: string file1, int &num_wizards
 ** Pre-Conditions: Correct wizards.txt file is given in correct format
 ** Post-Conditions: wiz is filled with wizards
** Function : create_wiz ** Description : This function creates the array full of all of the wizards given in the wizards . txt file ** Parameters : string file1 int &num_wizards ** Pre - Conditions : Correct wizards . txt file is given in correct format ** Post - Conditions : wiz is filled with wizards