cs162/assignments/assignment1/magic.cpp
/*********************************************************************
 * ** Function: check_files
 * ** Description: This function checks to make sure the two file names given as command line arguments actually exist and can be opened.
 * ** Parameters: char** argv, string &file1, string &file2
 * ** Pre-Conditions: Two command line arguments given
 * ** Post-Conditions: Files open
 * *********************************************************************/
check_files
Description: This function checks to make sure the two file names given as command line arguments actually exist and can be opened.
Parameters: char** argv, string &file1, string &file2
Pre-Conditions: Two command line arguments given
Post-Conditions: Files open
check_files Description : This function checks to make sure the two file names given as command line arguments actually exist and can be opened . Parameters : char ** argv string &file1 string &file2 Pre - Conditions : Two command line arguments given Post - Conditions : Files open
void check_files(char** argv, string &file1, string &file2) {
	file1 = argv[1];
	file2 = argv[2];
	ifstream f1;
	f1.open(file1.c_str(), ios::in);
	ifstream f2;
	f2.open(file2.c_str(), ios::in);
	if(f1.is_open() && f2.is_open()) {
		cout << "Files successfully loaded!" << endl;
		f1.close();
		f2.close();
	}
	else {
		cout << "One or more files don't exist or opened incorrectly!" << endl;
		f1.close();
		f2.close();
		exit(0);
	}
}
void check_files ( char * * argv , string & file1 , string & file2 ) { file1 = argv [ 1 ] ; file2 = argv [ 2 ] ; ifstream f1 ; f1 . open ( file1 . c_str ( ) , ios :: in ) ; ifstream f2 ; f2 . open ( file2 . c_str ( ) , ios :: in ) ; if ( f1 . is_open ( ) && f2 . is_open ( ) ) { cout << " " << endl ; f1 . close ( ) ; f2 . close ( ) ; } else { cout << " " << endl ; f1 . close ( ) ; f2 . close ( ) ; exit ( 0 ) ; } }
** Function: check_files
 ** Description: This function checks to make sure the two file names given as command line arguments actually exist and can be opened.
** Function : check_files ** Description : This function checks to make sure the two file names given as command line arguments actually exist and can be opened .