08-05-2011, 08:08 AM
What do you use to program with?
I'm guessing the crash you're getting is related to memory access problems, since you're using a lot of array's and pointers. These are pretty easy to correct with a good debugger. Sadly, I can only help if you're using Visual Studio or Visual Express. I don't like Microsoft, but there debuggers are really easy to work with (and the sole reason why I use Visual Studio)
What you could try (if you're running something from MS):
- run the program inside the IDE
- force a crash. When it happens, you need to "debug and view the call stack" or something along those line. The stack contains all data at the moment of execution, and is the easiest way of catching your bug.
- if you're using Visual Express/Studio, it'll show all the variables in the stack and highlight where it went wrong. It always boils down to the same problem: a pointer is being used which points to some random location instead of the proper object.
This might be because the object it's supposed to point to A) never got created B) was created inside a function, without using "new" to reserve space on the stack (and thus it got destroyed when the function ended) C) got lost in translating pointers to references to pointers to references etc etc.
If you actually look at the stack at the moment of the crash, it should become clear which data is missing. Then you just track down where you create the troubled object (and in 99% of all cases, smack yourself against the head because you forgot to reserve space with "new")
If you're not using a debugger, put "cout << somenumber << endl;" every even/odd line to locate the exact moment stuff starts crashing.
I'm guessing the crash you're getting is related to memory access problems, since you're using a lot of array's and pointers. These are pretty easy to correct with a good debugger. Sadly, I can only help if you're using Visual Studio or Visual Express. I don't like Microsoft, but there debuggers are really easy to work with (and the sole reason why I use Visual Studio)
What you could try (if you're running something from MS):
- run the program inside the IDE
- force a crash. When it happens, you need to "debug and view the call stack" or something along those line. The stack contains all data at the moment of execution, and is the easiest way of catching your bug.
- if you're using Visual Express/Studio, it'll show all the variables in the stack and highlight where it went wrong. It always boils down to the same problem: a pointer is being used which points to some random location instead of the proper object.
This might be because the object it's supposed to point to A) never got created B) was created inside a function, without using "new" to reserve space on the stack (and thus it got destroyed when the function ended) C) got lost in translating pointers to references to pointers to references etc etc.
If you actually look at the stack at the moment of the crash, it should become clear which data is missing. Then you just track down where you create the troubled object (and in 99% of all cases, smack yourself against the head because you forgot to reserve space with "new")
If you're not using a debugger, put "cout << somenumber << endl;" every even/odd line to locate the exact moment stuff starts crashing.