C++ exe code keeps crashing

Hello so I have this program that for now does nothing that keeps ignores the cin.get(code,7); , terminates procces and now it even crashes when it gets there.
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
#include <iostream>
#include <string.h>

using namespace std;
int main()
{
    char p[8],code[10],txt[1000];
    long long int sum=1,cod=1;
    int expl,i;
    cout<<"Welcome to CryptSec 1.0 created by Andu\nEnter the acces password (7 letters): ";
    cin.get(p,8);
    for(i=0;i<=5;i++)
        sum*=int(p[i]);
    sum/=int(p[6]);
    if(sum==12076374870)
    {
        cout<<"\nACCES GRANTED";cin.get();cin.get();cout<<"\nContinue     1\nInstructions 2\n";
        cin>>expl;
        if(expl==2)
            cout<<"\nThis program encrypts and decrypts text using a 5 letters code you enter.\nThe text can only be decrypted with the code it was encrypted with.";
        cin.get();
        cout<<"\n\nEncrypt 1\nDecrypt 2\n";
        cin>>expl;
        if(expl==1)
        {
            cout<<"\n\nEncrypting:\nEnter the 5 letters code: ";
            cin.get(code,7);          //!!!!!!!! HERE IT CRASHES AND IGNORES THIS cin.get
            for(i=0;i<=4;i++)
                cod*=int(code[i]);
            cod/=int(code[5]);
            cod/=int(code[6]);

        }
        if(expl==2)
        {
            cout<<"\n\nDecrypting:\nEnter the 5 letters code: ";
        }


    }
    else
        cout<<"\nACCESS DENIED";
    return 0;
}


Can anyone figure out what i did wrong. thank you all in advance.

It says proccess returned -1
Last edited on
Topic archived. No new replies allowed.