Need help debugging this (beginnerish)

Hello,

i'm a student currently and I'm stuck with my project because for some reason my container gets values in it that shouldn't exist. There's no place in my code that (at least I know of) that shows me input a value into that place. So it gets stuck in a looop and crashes. I have uploaded my whole project and it's on my Google Drive here... the IDE i use is cLion and same debugger. I know the values are going there from my debugger showing it but other then that the program simply crashes.

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

https://drive.google.com/file/d/0B1yOnHWN92guN3dkTlNHeUJOcE0/view?usp=sharing



Specifically it's this part



            for (int i = 0; i < enterCounter; ++i) {

                // checks if the object already has a term at 'i' equaling to the current term.
                // Performance -> it won't go through 70k to check for that term, only MAX 50

                if (testings[i].termYear == term) { // if term exists then ->

                    testings[i].numberSeen++; // tracks number of sections entered under this term.
                    testings[i].seenSectionNumber[testings[i].numberSeen] = section; // adds the section under the term

                    /*
                     * The Above line enters the section to the container but increased by counter of numberSeen.
                     * the numberSeen increases every time a new section is entered, thus,
                     * seenSectionNumber[counter] keeps the new section according to the numberSeen.
                    */

                    //todo-me "If the term exists in storage add to counter else go create term."

                    for (int j = 0; j < testings[i].numberSeen; ++j) {

                        if (testings[i].seenSectionNumber[j] == section) {

                            duplicate = true; // later used to enter increase the counter & enter the term !Duplicate.

                        }// if

                    }// for

                } // if

            } // for



PS the comments are meant for me, I copy pasted directly from my project.
Last edited on
Specifically line 15 executes when it shouldn't, for some odd reason

1
2
3
4
5

 if (testings[i].termYear == term)

//testings[i[.termYear gets a value even tho I've never declared it.


if you look at the full project it'll be a better point of view.
Never mind I think I got it, honestly I did nothing and it ran fine but now I Just gotta fix output...
Your container is an array of objects. Every element in the array contains an object, always, because it's just an array of those objects. You aren't creating objects individually and inserting them into your container. Your container is just a full array of objects.

//testings[i].termYear gets a value even tho I've never declared it. testings[i] is an object of type sections. It will always have at least the default value for termYear, " "
Last edited on
Topic archived. No new replies allowed.