COM1100 -- Winter2000 -- Yuhong Yin
11
Question 4 -- solution
• ifstream inFile; // declare an input file stream
    ofstream outFile; // declare an output file stream
    GetInputFile(inFile); // call GetInputFile (See slide 4)
    GetOutputFile(outFile); // call GetOutputFile (See slide 5)
    char ch; // declare a char variable
    while ( inFile.peek() != EOF ) { // test if at the End Of File
inFile.get(ch); // read one character a time from input file
if ( ch == `  `)
outFile.put(`*`); // replace the blank with a star
else
outFile.put(ch); // write(copy) the character to output file
    }
    inFile.close(); // close the input file stream
    outFile.close(); // close the output file stream