1234567891011121314151617181920212223242526
#include <iostream> #include <fstream> #include <ctime> using namespace std; int main () {time_t t = time(0); struct tm * now = localtime( & t ); string entry; ofstream myfile ("Journal.txt"); if (myfile.is_open()) { cout << "Enter todays journal entry" << endl; cin >> entry; myfile << (now->tm_year + 1900) << '-' << (now->tm_mon + 1) << '-' << now->tm_mday << endl; myfile << entry <<endl; myfile.close(); } else cout << "Unable to open file"; system ("pause"); }