// // copytext.cpp // CSC 215 // John Rogers // // This program copies one text file // to another. It does so using // file stream member functions for // performing character input/output. // #include #include #include int main() { char inputFilename[51]; char outputFilename[51]; ifstream inputFile; ofstream outputFile; char c; cout << "Please enter the name of the input file: "; cin >> inputFilename; inputFile.open(inputFilename); if (inputFile.fail()) { cout << "Unable to open the file " << inputFilename << endl; exit(1); } cout << "Please enter the name of the output file: "; cin >> outputFilename; outputFile.open(outputFilename); if (outputFile.fail()) { cout << "Unable to open the file " << outputFilename << endl; exit(1); } inputFile.get(c); while (! inputFile.eof()) { outputFile.put(c); inputFile.get(c); } inputFile.close(); outputFile.close(); return 0; }