simple program for sign in and sign up in c 2b 2b

Solutions on MaxInterview for simple program for sign in and sign up in c 2b 2b by the best coders in the world

showing results for - "simple program for sign in and sign up in c 2b 2b"
Clara
24 Jan 2019
1    #include<iostream.h>
2    #include<fstream.h>
3    #include<conio.h>
4    #include<stdio.h>
5    #include<string.h>
6
7    void register_user();
8    void login_user();
9    void main_menu();
10
11    int IsLoggedIn()
12    {
13        char username[20],password[20],un[20],pw[20];
14        cout<<"Enter Username: ";gets(username);
15        cout<<"Enter Password: ";gets(password);
16
17        ifstream read(username + ".txt");
18        getline(un,read);
19        getline(pw,read);
20
21        if(un==username && pw==password)
22        {
23            return 1;
24        }
25        else
26        {
27            return 0;
28        }
29    }
30
31    void main()
32    {
33        main_menu();
34    }
35
36    void main_menu()
37    {
38        int choice;
39        cout<<"1. Register\n2. Login\nYour Choice: "; cin>>choice;
40        switch(choice)
41        {
42            case 1: register_user(); break;
43            case 2: login_user(); break;
44            default: break;
45        }
46    }
47
48    void register_user()
49    {
50        char username[20], password1[20],password2[20];
51        cout<<"Enter Username: ";gets(username);
52        rev1:cout<<"Enter Password: ";gets(password1);
53        cout<<"Enter Password again: ";gets(password2);
54        while (password1!=password2)
55        {
56            goto rev1;
57        }
58        ofstream file;
59        file.open(username + ".txt");
60        file<<username<<endl<<password1;
61        file.close();
62    }
63
64    void login_user()
65    {
66        int chk=IsLoggedIn();
67        if(chk==1)
68        {
69            cout<<"Log in successfull!\n";
70        }
71        else
72        {
73            cout<<"Log in unsucessfull!\n";
74        }
75    }
76