Program Debugging Assistance needed!

Someone help me in debugging this entire program. I really need help

To see entire program go here: cpp.sh/3p2pq

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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
#include <iostream>
#include <stdlib.h>
#include <cstring>
using namespace std;

class User
{
private:
     char Username[20];
     char password[20];


public:
    void Create_new_user(const char * user2, const char * password2);
    void Login();
    User(const char * uname,const char * userpassword);


};
class Database
{
    public:
    char customername[20];
    char customeraddress[20];
    char town[10];
    char city[10];
    int phonenumber;
    char dateofbirth[20];
    int age;

    Database(const char * name,const char * address,const char * twn,const char * cty, int phnumber,const char * dob, int a);
    void print();
    void Agedetermination();
    void showmenu();

};

class AddCustomer : public Database
{
    protected:
        char nationality[20];

    public:
        AddCustomer(const char * name ,const char * address, const char * twn,const char * cty, int phnumber,const char * dob, int a,const char * nationalityproof);
        void namechange(const char * name);
        void addresschange(const char * address);

        void print();

};

User::User(const char * uname, const char * userpassword)
{
    strcpy(Username, uname);
    strcpy(password, userpassword);

}

void User::Login()
{
    if (Username == "Administrator" and password == "password" )
    {
        cout<<"You there \n";
        cout<<"Welcome! \n";
    }
    else
    {
        cout<<"Welcome Admin... \n";
        cout<<"Let's start... \n"<<flush<<endl;
            system("PAUSE");
            system("CLS");

    };

}

void User::Create_new_user(const char * user2, const char * password2)
{
    strcpy(Username, user2);
    strcpy(password, password2);
}

Database::Database(const char * name ,const char * address, const char * twn,const char * cty, int phnumber,const char * dob, int a)
{
    strcpy(customername, name);
    strcpy(customeraddress, address);
    strcpy(town, twn);
    strcpy(city, cty);
    phonenumber = phnumber;
    strcpy(dateofbirth, dob);
    age = a;

}

void Database::print()
{
    cout<<"Welcome to the database for Social Security. You are currently active as user Employee1 \n";
    cout<<"----------------------------------------------------------------- \n";
    cout<<"The customer's name is "<<customername<<". \n"
        <<"The customer's address is "<<customeraddress<<", "<<town<<city<<". \n";


    cout<<"The age of the customer is "<<age<<". \n"
        <<"The customer's date of birth is "<<dateofbirth<<". \n";

}

void Database::Agedetermination()
{
    //determining age from date of birth
    if (age >= 18)
    {
        cout<<"The customer is a legal adult \n";
    }
    else if (age < 18)
    {
        cout<<"The customer is a minor \n";
    };

}

void Database::showmenu()
{
    cout<<"Press 1, 2, 3 or  4 \n"
        <<"1. Adding a new customer's information \n"
        <<"2. Accessing an existing customer's information \n"
        <<"3. Editing an existing customer's information \n"
        <<"4. Exit \n"<<endl;
}

AddCustomer::AddCustomer(const char * name,const char * address,const char * twn,const char * cty,int phnumber,const char * dob, int a,const char * nationalityproof) : Database(name, address, twn, cty, phnumber, dob, a)
{
    strcpy(nationality, nationalityproof);
}

void AddCustomer::namechange(const char* name)
{

    strcpy(customername, name);
    cout<<"The new customer's name is "<<customername<<". \n"<<endl;
}


void AddCustomer::addresschange(const char* address)
{

    strcpy(customeraddress, address);
    cout<<"The new customer's name is "<<customeraddress<<". \n"<<endl;
}

void AddCustomer::print()
{
    cout<<"Welcome to the database for Social Security. You are currently active as user Employee1 \n";
    cout<<"----------------------------------------------------------------- \n";
    cout<<"The customer's name is "<<customername<<". \n"
        <<"The customer's address is "<<customeraddress<<", "<<town<<city<<". \n";


    cout<<"The age of the customer is "<<age<<". \n"
        <<"The customer's date of birth is "<<dateofbirth<<". \n"
        <<"The customer's nationality is "<<nationality<<". \n";

}

int main()
{

      char uname[20];
      char userpassword[20];
      char user2[20]; char password2[20];
      char name[20];
      char address[20];
      char tc[4];
      char twn[20];
      char cty[20];
      int phnumber;
      char dob[20];
      int a;
      char nationalityproof[20];
      int choice;
      int choice2;


      cout<<"Welcome to the Social Security Program. \n"<<flush
         <<"If you don't have an account enter the letter 'N' \n"<<flush
         <<"\n To begin. Please Login. \n"<<flush<<endl;

     User u(uname, userpassword);
     cout<<"Username: \n";
     cin.getline(uname,20);

     cout<<"Password: \n";
     cin.getline(userpassword,20);

        if (uname == "N" || uname == "n")
     {
         cout<<"Welcome Guest. \n Let's create your account \n To continue, follow the instructions below \n";
         cout<<"Please enter your new username \n"<<endl;
         cin.getline(user2, 20);
         cout<<endl;
         cout<<"Please enter your new password \n"<<endl;
         cin.getline(password2, 20);
         cout<<endl;
         cout<<"Please wait while your new profile is being created... \n"<<flush;
         u.Create_new_user(user2, password2);
         system("PAUSE");
         system("CLS");
     };
Last edited on
Your chars are uninitialized, so it's good to initialized them to nothing by doing this

 
char myChar[200] = {'\0'};


A few of your getline seems to skip. Try inserting a cin.ignore() above or below it to see if it fixes anything.


Also, can you be a bit more specific? What errors do you need help with in your program?
Last edited on
Topic archived. No new replies allowed.