COM1100 -- Winter2000 -- Yuhong Yin
4
Example 1 – ifstream&
nWrite a function GetInputFile that will receive one input file stream as argument, and will open the file stream by asking the user to enter a file name.
nvoid GetInputFile(ifstream& InFile){
       string InFileName;
       RequestString("Enter input file name: ", InFileName);  // Get file name
 
       InFile.open(InFileName.c_str());        // If a name was entered, try to open the file
        if (!InFile){       // test if the open operation is successful
cout << "Cannot open " << InFileName << endl;
exit(1);
      }
}