Journal

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#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");
}


So Im making journal. This here is what I have so far. The problem is that the program only writes 1 word and overwrites the previous entry. I need alittle help and guidance for this. Im 11 so keep it as simple as possible. TY
Topic archived. No new replies allowed.