#include #include using namespace std; int main() { // declare variable for accessing output file ofstream myfile; string month = "april"; int day = 20; // open output file myfile.open( "hello.dat" ); // check that file opened okay if ( ! myfile ) { cout << "error opening file :-( \n"; exit( 1 ); } cout << "file opened a-okay :-)\n"; // write a message to the file cout << "writing messages to file...\n"; myfile << "hello ryan!\n"; myfile << "today is " << month << " " << day << endl; // close the file cout << "closing file\n"; myfile.close(); cout << "that's all folks!\n"; } // end of main()