Help with c++, saving to txt and etc

May 30, 2013 at 10:50am
Hi, I'm quite new to c++, but I am trying to test myself by creating a kind of virtual journal, and I have 2 problems.
So the problem I am having is I can get them to start entering their journal entry, but (don't judge me), I can't figure out how to get them to save the entry to a txt file, I think it's something like: ofstream savefile.

2. I can get them to start their entry, but how do I get them to say their finished entering their info, so they can save, open old entries, and other stuff.

Thanks guys, big help.

PS: If anyone has any tips they can give me, or another challenge, I've already created a fully working calculator.

Heres my current code. Any help would be amazing, thanks.

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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <cstdlib>
#include <iostream>

using namespace std;

string name;
string Lname;
int age;
int choice;
string entry;

int main(int argc, char *argv[])
{
//Log In
cout << "Welcome to your Journal, my name is Sam, I will be your guide throughout this program." << endl;
cout << "Please enter your name: ";
cin >> name;
cout << "Thank you, " << name << endl;
cout << "Now please enter your surname: ";
cin >> Lname;
cout << "So your full name is: " << name << " " << Lname << "?" << endl;
cout << "1. Yes, 2. No" <<endl;
cin >> choice;
if(choice==2)
{
return 0;
}
if(choice==1)
{
cout << "Great! What a nice name. Now please enter your age: ";
cin >> age;
cout << "What a great age." << endl;
cout << "It's time to start writing your journal entry." << endl;
cout << "Dear Diary, " << endl;
cin >> entry;
cout << "
}

system("PAUSE");
return EXIT_SUCCESS;
} 

May 30, 2013 at 11:55am
It may be useful to look at the tutorial page on file i/o (input / output)
http://www.cplusplus.com/doc/tutorial/files/

I realise this doesn't answer all of your questions, but i think the background knowledge should give you more of an idea as to how to proceed.
May 30, 2013 at 9:09pm
Yeah thanks,

That kind of helps, but not REEAALLY what I'm looking for.

Thanks anyway,

Do you maybe have any tips or other harder programs I could write? This is my first coding language and I only started 2 days ago.
May 30, 2013 at 9:10pm
How about running through these?
http://www.cplusplus.com/articles/N6vU7k9E/
Topic archived. No new replies allowed.