// This program demonstrates reading from one file // and writing to a second file. #include #include #include // Needed for the toupper function using namespace std; int main() { // Variables needed to read and write files. const int LENGTH = 81; ifstream inFile; // For input file ofstream outFile("out.txt"); // For output file char fileName[LENGTH], ch, ch2; // Open input file cout << "Enter a file name: "; cin >> fileName; inFile.open(fileName); if (!inFile) { cout << "Cannot open " << fileName << endl; return 0; } // Read characters from input file and write // uppercased versions of the character to the // output file. while (inFile.get(ch)) { ch2 = toupper(ch); outFile.put(ch2); } // Close files. inFile.close(); outFile.close(); cout << "File conversion done.\n"; return 0; }