Help with file output?

Hi, i'm trying to create some kind of a login system. A very basic one.

pseudocode would be something like:

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
Welcome, please make a selection

1.) Login
2.) Register

what would you like to do?

if 1

please enter your username:
please enter your password:

if user exists

    hello user

if user does not exist

    please register


if 2

 what would you like your username to be

 what would you like your password to be

   when finished entering in both desired username and pass, write to some file to keep a record and remember for the next time this user wants to log in again.


is this doable?

if so, how could i achieve this?

(I do not want the code written out for me, but with that said i do not know if there are certain commands that i do not know exist)

Thank you if you can help.
is this doable?
Yes
i do not know if there are certain commands that i do not know exist
You should know about flow control: http://www.cplusplus.com/doc/tutorial/control/
and variables: http://www.cplusplus.com/doc/tutorial/variables/
also file handling: http://www.cplusplus.com/doc/tutorial/files/
flow control is not something i know about. however variable and file handling (although i'm guessing this has to do with separate header files) is something i know about. thank you for the links.
for this i guess you need to use the
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
switch (choice)

case 1;

function // what do do after choosing choice 1

break;

case 2;

function // ''''''''''''''after choosing choice 2

break;
.
.
.
.
.



and so on!!

try to solve it yourself .. post what you`ll get here ..then if something wrong mention and we`ll help you
actually this is what i already have written.

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
int main()
{
    char sel;
    cout << "Welcome to the game, what would you like to do?" << endl;
    cout << "1. Login" << endl;
    cout << "2. Register" << endl;
    cout << "Selection: ";
    cin >> sel;
    
    switch (sel) //switch
    {
        case 1:
            login();
            break;
        case 2:
            reg();
            break;
    }
    
    void login() //login func
    {

    }
    
    void reg() //register
    {
        system("cls");
        string username;
        string password;
        string FileName;
        cout << "What would you like your username to be?: ";
        cin >> username << endl;
        cout << "What would you like your password to be?: ";
        cin >> password << endl;
        
    }
    
    return 0;
}
so the output for the user is out after choosing one of the cases ,, and say that the user intered the first one he'd log in and then you have to input a function to check if he wntered right or wrong answers to either go back and login again or if all true to continue without goin back to start!!

and for choice two you`ll not need the check... and the user continues
Last edited on
Topic archived. No new replies allowed.