Segmentation Fault core dumped

closed account (z0MN6Up4)
Every time i run my program, every part of the program runs until I reach this point and then it says segmentation fault core dumped.
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
void
VENDING_SUPERVISOR::ITEM_UPDATE()
{
        int PASSWORD_RESULT;
        int SUPER_CODE_ENTRY;
        string SUPER_ITEM_NAME_ENTRY;
        int ITEM_INDEX;
        int SUPER_ENTRY;
        int NOOF_ITEMS_TO_ADD;

        cout << "ENTER YOUR NAME" << endl;
        out_file << "ENTER YOUR NAME" << endl;
        cin >> SUPER_NAME;


        PASSWORD_RESULT = VERIFY_PASSWORD();
        if(PASSWORD_RESULT == 1)
        {
                cout << "WELCOME SUPERVISOR " << SUPER_NAME << endl;
                out_file << "WELCOME SUPERVISOR " << SUPER_NAME << endl;
                cout << "WHICH ITEM YOU WANT TO UPDATE?" << endl;
                out_file << "WHICH ITEM YOU WANT TO UPDATE?" << endl;
                cout << "ENTER ITEM CODE" << endl;
                out_file << "ENTER ITEM CODE" << endl;
                cin >> SUPER_CODE_ENTRY;
                cout << "ENTER ITEM NAME" << endl;
                out_file << "ENTER ITEM NAME" << endl;
                cin >> SUPER_ITEM_NAME_ENTRY;


  ITEM_INDEX = CHECK_SUPER_CODE(SUPER_CODE_ENTRY, SUPER_ITEM_NAME_ENTRY);

                if(ITEM_INDEX == -1)
                {
                        cout << "NO SUCH ITEM" << endl;
                        out_file << "NO SUCH ITEM" << endl;
                }
                else
                {
                        cout << "CURRENTLY WE HAVE " << 
                        ITEM_COUNT[ITEM_INDEX] << " ITEMS OF "  
                        <<  ITEM_NAME[ITEM_INDEX] << endl;
                       
                        out_file << "CURRENTLY WE HAVE " 
                        <<  ITEM_COUNT[ITEM_INDEX] 
                        << " ITEMS OF " << ITEM_NAME[ITEM_INDEX] << endl;

                        cout << "HOW MANY ITEMS DO YOU WANT TO ADD? (MAX 3)" 
                        <<  endl;
                        
                        out_file << "HOW MANY ITEMS DO YOU WANT TO ADD? (MAX 3)"      << endl;
                        
                        cin >> NOOF_ITEMS_TO_ADD;
                 }
Last edited on
I don't see a question.
closed account (z0MN6Up4)
Thank you, I posted up the question. If you need any additional info I can post it. Thanks.
You haven't shown enough of your program to be certain, nor have you indicated the line on which the segmentation fault is occurring, but my best guess is that CHECK_SUPER_CODE is returning an ITEM_INDEX that is out of bounds and that you're trapping at line 11 trying to reference an element of ITEM_COUNT that is out of bounds.
Last edited on
Topic archived. No new replies allowed.