COM1100 -- Winter2000 -- Yuhong Yin
11
Steps in using Files – 2 (cont’d)n
nOpen a file by indicating the file name
nIf define file name as string
nstring inFileName;
n RequestString("Enter data file name", inFileName);
n    ifstream MyInFile;
n    MyInFile.open(inFileName.c_str());
nstring outFileName;
n RequestString("Enter out file name", outFileName);
n   ofstream myOutFile;
n    myOutFile.open(outFileName.c_str());
nHere, function inFileName.c_str() converts a string to a character array
n
n