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;
}
|