Notepad program

Is there any way to create a console notepad program in c++? I tried creating a string, like note1, and I would do this:

cout << "What would you like to do?" << endl << endl;
cout << "1. Compose." << endl;
cout << "2. Read." << endl;

cin >> choice;

if(choice==1)
{
system("cls")
cin >> note1;
system("cls");
cout << main();
}

after that, they would get back to that screen, if they put in 2 for read, I would cout "note1", and it wouldnt like, let me read what i put.

Any ideas?

Try something like this:

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
#include <iostream>
#include <cstdlib>

int main()
{
    using namespace std;
    int choice;
    do {
    cout << "What would you like to do ?" << endl;
    cout << "1. Compose" << endl;
    cout << "2. Read" << endl;
    cout << "3. Exit" << endl;
    cin >> choice;

    if (choice == 1)
    {
        //do what you want here
    }

    else if (choice == 2)
    {
        ;//do what you want here
    }

    else
    {
        exit(0);
    }

    }while (choice != 3);
}
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
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
    string note1, choice;
    
    cout << "What would you like to do ?" << endl; //Main screen
    cout << "1. Compose" << endl;
    cout << "2. Read" << endl;
    cout << "3. Exit" << endl;
    cin >> choice;

    if (choice == "1")        //If they would like to compose
    {
        system("cls");
        cin >> note1;
        system("PAUSE");
        system("cls");\
        cout << main();
    }
    else
    {
        if(choice == "2")          //If they would like to read
        {
                  system("cls");
                  cout << note1 << endl << endl;
                  system("PAUSE");
                  system("cls");
                  cout << main();
        }
        else
        {
            if(choice == "3")     //If they want to exit
            {
                      return 0;          
            }    
            else      //If they don't enter one of the choices
            {
                system("cls");
                cout << choice << " was not an option.." << endl << endl;
                system("PAUSE");
                system("cls");
                cout << main();        
            }
        }
    }
}


That's what I came up with. Still doesn't run correctly. It doesn't save what I wrote.
Anyone have any ideas? This is kinda important.
I am a slight bit confused. From what I'm getting, you are trying to read from and write to a file. If this is the case, try looking up the
#include <fstream>
header file.
Topic archived. No new replies allowed.