/*****************************************************************/ /* Author: Chang */ /* Aim for: CS135 class */ /* Problem: A simple program illustrate basic file operations. */ /*****************************************************************/ //preprocessor directives #include #include // include file I/O header using namespace std; int main () { ofstream myfile; // declare output stream object myfile.open ("example.txt"); // open a specific file if(myfile.is_open()) { myfile << "Writing this to a file.\n"; // write to file cout << "Finish writing this to a file.\n"; myfile.close(); // close file } else { cout << "Error with file opening! " << endl; } system("PAUSE"); return 0; }