// File name: modify.cpp // Topic: file input/output in C++ // Created: March 13, 2000 // Author: Elena Machkasova #include #include // using file input-output #include // using islower, toupper int main() { // a character variable to read character-by-character char c; // declare input and output streams ifstream inFile; ofstream outFile; // Exercise 2: open input and output files: // input file: data, output file: result2 // checking if the files have opened correctly: if (!inFile) { //print error message to standard error stream: cerr << "Can not open input file" << endl; exit(1); } if (!outFile) { //print error message to standard error stream: cerr << "Can not open output file" << endl; exit(1); } // input-outpur loop goes until the end of file // There is no wrong data for unformatted character-by-character input // Exercise 2: input a character c using method get(c) in the condition // of the while loop: while ( ) { // if c is a lower-case letter, convert it to upper case if (islower(c)) c = toupper(c); // Exercise 2: output c to the output file using put(c) method: } // Exercise 2: close input and output files: return 0; }