//************************************************************************** // function to attach a file to an input stream // // parameter usage : // iStr -- exports the stream that the file was attached to // filename -- imports the name of the file to be opened and // exports the name of the file that was opened //************************************************************************** void openIn(ifstream& iStr, string& filename) { iStr.open(filename.c_str()); while (!iStr) { // unable to open file iStr.clear(); // and clear error flag cout << "Unable to open file!!! " << filename // and complain << ". Re-enter filename -- "; getline(cin, filename); // get replacement filename iStr.open(filename.c_str()); // and try to open it } }