'* How to solve a vector related C++ program with Process returned -1073741819 (0xC0000005) *

[enter image description here][1]


As I am trying to code a program for ATM SYSTEM ,I am facing a problem with the Pin_change function in the second Derived class Access when I call this funtion from Main() method.

Please Help me here to, How to solve the mistake of Process returned -1073741819 (0xC0000005) at the call of Pin_change () from Main() Method ?? It terminates their automatically.. I will Solve it again with your best Suggestion.


     #include <iostream>
            #include <string.h>
            #include <vector>
            using namespace std;
            
            class LOGIN
            {
            public:
            
                int sz;
                vector <string> CARD_NO;
                vector <string> pin_number;
                vector <string> Account_Number;
                vector <string> Person_name;
            
                public:
            
                string card_num;
            
                    vector<string> card_no()
                    {
                        string cnp1,cnp2,cnp3,cnp4;
            
                        cout<<"Enter how many ATM card numbers you want to include to be accessed :"<<endl;
                        cin>>sz;
            
                        string card_nop1[sz];
                        string card_nop2[sz];
                        string card_nop3[sz];
                        string card_nop4[sz];
            
                        for(int i=0;i<sz;i++)
                        {
            
                    cout<<"Please enter the ATM Card Number of Bank Account Holder here..\n Please press enter after every 4 (Four) digits
        "<<endl;
                            cin>>cnp1>>cnp2>>cnp3>>cnp4;
            
                            card_nop1[i] = cnp1;
                            card_nop2[i] = cnp2;
                            card_nop3[i] = cnp3;
                            card_nop4[i] = cnp4;
            
                            cout<<card_nop1[i]<<" "<<card_nop2[i]<<" "<<card_nop3[i]<<" "<<card_nop4[i]<<endl;
            
                        }
            
                        for(int j=0;j<sz;j++)
                        {
                            string CARD_NUM1 = "";
                            string CARD_NUM2 = "";
                            string CARD_NUM = "";
            
                cout<< "CARD NUMBERS ARE : " <<j<<" -> "<<card_nop1[j]<<" "<<card_nop2[j]<<" "<<card_nop3[j]<<" "<<card_nop4[j]<<"\n"<<endl;
                            CARD_NUM1 = CARD_NUM1 + card_nop1[j] + card_nop2[j];
                            CARD_NUM2 = CARD_NUM2 + card_nop3[j] + card_nop4[j];
            
                            CARD_NUM = CARD_NUM1 + CARD_NUM2;
            
                            cout<<"CARD_NUM is :- "<<CARD_NUM<<"\n"<<endl;
            
                            CARD_NO.push_back(CARD_NUM);
            
                        cout<<"CAPACITY of CARD NUMBER is = "<<CARD_NO.capacity()<<endl;
            
                        }
                            return CARD_NO;
                    }
            
                    vector<string> pin_no()
                    {
            
                    string pnum;
                    string pin_num[sz];
            
                        cout<<"Please enter the 4 PIN numbers of the respective ATM card numbers mentioned above.."<<endl;
            
                        for(int k=0;k<sz;k++)
                        {
            
                        cout<<"\n Please enter the "<<k+1<<" ATM PIN Number of Bank Account Holder here.."<<endl;
                        cin>>pnum;
            
                            pin_num[k] = pnum;
                        }
            
                        for(int l=0;l<(sizeof(pin_num)/sizeof(pin_num[0]));l++)
                        {
                            string pin_digits = "";
                            cout<<"PIN NUMBERS ARE: " <<l<<" ->  "<<pin_num[l]<<"\n"<<endl;
                            pin_digits = pin_digits + pin_num[l];
                            pin_number.push_back(pin_digits);
            
                        }
            
                        return pin_number;
            
                    }
            
                    vector <string> pAcc_no()
                    {
                            string acc_num;
            
                            for(int q = 0;q<sz;q++)
                            {
                                cout<<"Please enter the Account Number of the "<<q<<" person : "<<endl;
                                cin>>acc_num;
            
                                cout<<"Account Number is -> "<<acc_num<<endl;
            
                                Account_Number.push_back(acc_num);
            
                                cout<<"Capacity of Account_NUM is = "<<Account_Number.capacity()<<endl;
            
                            }
                            for (int r = 0;r<sz;r++)
                            {
                                cout<<"Account Number is = "<<Account_Number[r]<<endl;
                            }
                        return Account_Number;
            
                    }
            
                    vector <string> pname()
                    {
                        string p_nm;
            
                        for (int s = 0;s<sz;s++)
                        {
                            cout<<sz<<" s :- "<<s<<endl;
                            cout<<"Enter the name of account holder : "<<endl;
                            cin>>p_nm;
            
                            cout<<"Name is : "<<p_nm<<endl;
            
                            Person_name.push_back(p_nm);
                            cout<<"Capacity of Person_name is : "<<Person_name.capacity()<<endl;
                        }
            
                             for(int t = 0;t<sz;t++)
                             {
                                cout<<"Person's Name is : "<<Person_name[t]<<endl;
                             }
            
                        return Person_name;
            
                    }
            
            
            };
            
            class Access : public LOGIN
            {
            public:
            
                void acc_ass(vector <string> &v1,vector <string> &v2,vector <string> &v3,vector <string> &v4)
                    {
                        string ucn,upn;
                        string CARD_NUMBER[sz],PIN_NUMBER[sz],ACC_NO[sz],P_NAME[sz];
                        int flag0 = 0,flag1 = 0,flag2 = 0,flag02 = 0;
                        int chance = 3,c = 0,p = 0;
            
                        for(int o = 0;o<sz;o++)
                        {
                            CARD_NUMBER[o] = v1[o];
                            PIN_NUMBER[o] = v2[o];
                            ACC_NO[o] = v3[o];
                            P_NAME[o] = v4[o];
            
                            cout<<"CARD_NUMBER IS HERE : "<<CARD_NUMBER[o]<<" AND ITS PIN NUMBER IS : "<<PIN_NUMBER[o]<<endl;
                            cout<<"The Account Number is : "<<ACC_NO[o]<<" \n Person's Name is : "<<P_NAME[o]<<endl;
                        }
            
                        cout<<"Please enter your 16 digit ATM CARD NUMBER to access your account now.."<<endl;
                        cin>>ucn;
            
                        for(int m = 0;m<sz;m++)
                        {
                            cout<<"Value of m is : "<<m<<endl;
            
                                if(ucn == CARD_NUMBER[m])
                                {
                                    flag1 = 1;
                                }
                                if(flag1 == 1)
                                {
                                    cout<<"\t\t....Welcome...."<<endl;
            
                                    flag0 = 1;
                                    //break;
                                    while(c<chance)
                                    {
            
                                    cout<<"Value of c is : "<<c<<endl;
            
                                    cout <<"Now, Please enter your PIN NUMBER here.."<<endl;
                                    cin>>upn;
            
                                        if(upn == PIN_NUMBER[m])
                                        {
                                            flag2 = 1;
                                        }
            
                                        if (flag2 == 1)
                                        {
                                            cout<<"Please select which operation you want to perform .."<<endl;
                                            flag02 = 1;
                                            cout<<"\t\t==>> *WELCOME* <<=="<<endl;
                                            cout<<"\t\tMr/Mrs. "<<P_NAME[m]<<endl;
                                            cout<<"Your Account Number :- "<<ACC_NO[m]<<endl;
                                            break;
            
                                        }
                                        else
                                        {
                                            cout<<"THE PIN NUMBER YOU ENTERED IS INCORRECT .. !! \n     PLEASE ENTER CORRECT PIN NUMBER
        AGAIN    "<<endl;
                                        }
                                        c++;
                                    }
            
                                    cout<<"Outside of while loop now.."<<endl;
            
                                    if(c == 3)
                                    {
                                        cout<<"You have tried 3 incorrect attempts , please try after 24 Hours Now.."<<endl;
                                        break;
                                    }
                                }
                                else if(m == (sz-1))
                                {
                                    cout<<"No Match \n Please enter carefully.."<<endl;
                                    break;
                                }
            
                                if(flag0 == 1 && flag02 == 1)
                                {
                                    cout<<"Flag0 is now 1 "<<endl;
                                    cout<<"Flag02 is now 1"<<endl;
                                    cout<<"Value of m is : "<<m<<endl;
                                    break;
                                }
                            }
            
                        cout<<"Inside Account access method now.."<<endl;
                    }
            
                    void Pin_change(vector <string> &vec5,vector <string> &vec6) // unable to solve from here..
                    {
                        int c2 = 0,c3 = 0,c4 = 0;
                        vector <string> pinlist;
                        vector <string> cardlist;
                        string new_pin_nm,Cnew_pin_nm,upin_no,ucard_no;
            
                        for (int pl = 0;pl<sz;pl++)
                        {
                            cardlist[pl] = vec5[pl];
                            pinlist[pl] = vec6[pl];
            
                            cout<<"CARD NUMBER List : "<<cardlist[pl]<<endl;
                            cout<<"PIN NUMBER List : "<<pinlist[pl]<<endl;
                        }
            
                        cout<<"Please enter your 16 digit ATM CARD NUMBER here...."<<endl;
                        cin>>ucard_no;
            
                        cout<<"Please enter your current PIN NUMBER "<<endl;
                        cin>>upin_no;
            
                         do
                        {
                        for(int u = 0;u<sz;u++)
                        {
                            if(ucard_no == cardlist[u])
                            {
                                do
                              {
            
                                if (upin_no == pinlist[u])
                                {
                                    do
                                    {
            
                                    cout<<"Now, Please enter new PIN NUMBER to change "<<endl;
                                    cin>>new_pin_nm;
                                    cout<<"Please,Re-enter your new PIN NUMBER to confirm "<<endl;
                                    cin>>Cnew_pin_nm;
            
                                        if(new_pin_nm == Cnew_pin_nm)
                                        {
                                            pinlist[u] = Cnew_pin_nm;
                                            cout<<endl;
                                        }
                                        else
                                        {
                                            cout<<"The New PIN NUMBER AND CONFIRM PIN NUMBER NOT MATCHED \n Please re-enter both the numbers
        .."<<endl;
            
                                            c2++;
                                            cout<<"Value of c2 : "<<c2<<endl;
            
                                        }
            
                                    }while( c2<4 );
                                    cout<<"Outside of while loop now.."<<endl;
                                }
                                else
                                {
                                    cout<<"The PIN NUMBER YOU ENTERED DID NOT MATCH \n Please enter you correct PIN Number .."<<endl;
                                    cout<<"Please enter your current PIN NUMBER "<<endl;
                                    cin>>upin_no;
                                    c3++;
                                    cout<<"Value of c3 : "<<c3<<endl;
                                }
                              }while(c3 <2 );
                            }
                            else if(u == (sz-1))
                            {
                                cout<<"Please Re-Enter correctly Your 16 digit ATM CARD NUMBER ..!!"<<endl;
                                cout<<"Please enter your 16 digit ATM CARD NUMBER here...."<<endl;
                                cin>>ucard_no;
                                c4++;
                                cout<<"Value of c4 : "<<c4<<endl;
                            }
                          }
                        }while(c4<2);
                    }
            };
            
            int main()
            {
                vector <string> vec1,vec2,vec3,vec4;
                LOGIN lg;
                Access as;
                vec1 = as.card_no();
                vec2 = as.pin_no();
                //vec3 = as.pAcc_no();
                //vec4 = as.pname();
            
            //    for(int v = 0;v<vec3.capacity();v++)
            //    {
            //        cout<<"The Account Number : "<<vec3[v]<<endl;
            //        cout<<"The Name is : "<<vec4[v]<<endl;
            //    }
                //lg.acc_ass();
                cout<<vec1.capacity()<<"  "<<vec2.capacity()<<" "<<vec3.capacity()<<" "<<vec4.capacity()<<endl;
            
                for(int vec=0;vec<vec1.capacity();vec++)
                {
                    cout<<"VECTOR VEC1 HAS VALUES AS : "<<vec1[vec]<<endl;
                    cout<<"VECTOR VEC2 HAS VALUES AS : "<<vec2[vec]<<endl;
                    //cout<<"VECTOR VEC3 HAS VALUES AS : "<<vec3[vec]<<endl;
                    //cout<<"VECTOR VEC4 HAS VALUES AS : "<<vec4[vec]<<endl;
                }
            
                cout<<"HELLO"<<endl;
            
                //as.acc_ass(vec1,vec2,vec3,vec4);
                cout<<"Now Function to Change PIN NUMBER"<<endl;
                as.Pin_change(vec1,vec2);  // <-- funtion() call to change customer's PIN NUMBER 
                       // by passing 16 digit ATM CARD NUMBER and PIN NUMBER as the parameters ..
            
                return 0;
            }

***

        **strong text**`enter code here
    
       ***void Pin_change(vector <string> &vec5,vector <string> &vec6) // unable to solve from here..
                    {
                        int c2 = 0,c3 = 0,c4 = 0;
                        vector <string> pinlist;
                        vector <string> cardlist;
                        string new_pin_nm,Cnew_pin_nm,upin_no,ucard_no;
            
                        for (int pl = 0;pl<sz;pl++)
                        {
                            cardlist[pl] = vec5[pl];
                            pinlist[pl] = vec6[pl];
            
                            cout<<"CARD NUMBER List : "<<cardlist[pl]<<endl;
                            cout<<"PIN NUMBER List : "<<pinlist[pl]<<endl;
                        }
            
                        cout<<"Please enter your 16 digit ATM CARD NUMBER here...."<<endl;
                        cin>>ucard_no;
            
                        cout<<"Please enter your current PIN NUMBER "<<endl;
                        cin>>upin_no;
            
                         do
                        {
                        for(int u = 0;u<sz;u++)
                        {
                            if(ucard_no == cardlist[u])
                            {
                                do
                              {
            
                                if (upin_no == pinlist[u])
                                {
                                    do
                                    {
            
                                    cout<<"Now, Please enter new PIN NUMBER to change "<<endl;
                                    cin>>new_pin_nm;
                                    cout<<"Please,Re-enter your new PIN NUMBER to confirm "<<endl;
                                    cin>>Cnew_pin_nm;
            
                                        if(new_pin_nm == Cnew_pin_nm)
                                        {
                                            pinlist[u] = Cnew_pin_nm;
                                            cout<<endl;
                                        }
                                        else
                                        {
                                            cout<<"The New PIN NUMBER AND CONFIRM PIN NUMBER NOT MATCHED \n Please re-enter both the numbers
        .."<<endl;
            
                                            c2++;
                                            cout<<"Value of c2 : "<<c2<<endl;
            
                                        }
            
                                    }while( c2<4 );
                                    cout<<"Outside of while loop now.."<<endl;
                                }
                                else
                                {
                                    cout<<"The PIN NUMBER YOU ENTERED DID NOT MATCH \n Please enter you correct PIN Number .."<<endl;
                                    cout<<"Please enter your current PIN NUMBER "<<endl;
                                    cin>>upin_no;
                                    c3++;
                                    cout<<"Value of c3 : "<<c3<<endl;
                                }
                              }while(c3 <2 );
                            }
                            else if(u == (sz-1))
                            {
                                cout<<"Please Re-Enter correctly Your 16 digit ATM CARD NUMBER ..!!"<<endl;
                                cout<<"Please enter your 16 digit ATM CARD NUMBER here...."<<endl;
                                cin>>ucard_no;
                                c4++;
                                cout<<"Value of c4 : "<<c4<<endl;
                            }
                          }
                        }while(c4<2);
                    }***
  [1]: https://i.stack.imgur.com/BBRWh.png


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source