register code c 2b 2b

Solutions on MaxInterview for register code c 2b 2b by the best coders in the world

showing results for - "register code c 2b 2b"
Tommaso
08 May 2020
1#include <iostream>
2#include <string>
3#include <stdlib.h>
4#include <fstream>
5
6using namespace std;
7
8
9void mainmenu();
10
11
12int choice; 
13bool cinfail; 
14int confirmation; 
15string username, password, password2;
16
17void writetofile(string username){
18    ofstream writefile;
19    string file = username+".txt";
20    writefile.open(file.c_str());
21    writefile << password;
22    writefile.close();
23    mainmenu(); }
24
25void login(){
26    cout << "You are being logged in!";}
27
28
29void registerpassword(){
30    cout << "Please enter the password:" << endl;
31    cin >> password;
32    cout << "Please renter your password:" << endl;
33    cin >> password2;
34    if (password == password2){
35        cin.clear();
36        cin.ignore(10000,'\n');
37        writetofile(username);
38        exit(1);
39    }
40    else;{
41        cout << "Sorry invalid" << endl;
42        registerpassword();
43    }}
44
45
46void registerme(){
47    cout << "Please enter your username: " << endl;
48    getline(cin, username);
49    cout << "\nUsername -  \""<< username << "\"\nConfirm? \n\n[1] Yes\n[2] No" << endl;
50    cin >> confirmation;
51    if (confirmation == 1){
52        registerpassword();
53    }
54
55    else; {
56        cout << "Sorry invalid input, Please try again" << endl;
57        cin.clear();
58        cin.ignore(10000,'\n');
59        registerme();
60    }}
61
62
63void exit(){
64    exit(0);}
65
66void mainmenu(){ cout << "Hello, Would you like to log in or register\n[1] Login\n[2] Register\n[3] Exit" <<endl; cin >> choice; do{
67    cinfail = cin.fail();
68    cin.clear();
69    cin.ignore(10000,'\n');
70
71    }while(cinfail == true);{
72        switch(choice){
73            case 1:
74                login();
75                break;
76
77            case 2:
78                registerme();
79                break;
80
81            case 3:
82                exit();}}} 
83
84main(){ 
85mainmenu(); 
86}
87
similar questions
queries leading to this page
register code c 2b 2b