Electrical and Computer Engineering
8 of 29
UAH
CPE 112
Run-Time Input of File Names
•inFile.open(“datafile.dat”) restricts us, we can’t run that program on another file, we’d like to make the file name an input to the program
•To do so, we need code like the following:
–ifstream inFile;
–string fileName;
–
–cout << “Enter the input file name: ”;
–cin >> filename;
–inFile.open(fileName.c_str());