Code crashing on runtime
Can someone take a look at why my code is crashing as soon as .exe come up but compiles fine?
It is a program used to read all the height and depth info on earth from tbase.bin, and then convert it to display some info. Basicly, all depth and height info are stored as binary, and then in a 2d array that portrays a map of Earth. From it, you can get a bunch of info
Did you try to use a debugger?
yes i compiled and used a debugger. It didnt work
It crashed when the .exe came up
> static const int rowNum = 2160;
> static const int colNum = 4320;
> double AVERAGE_LAT_DIST;
> short array[rowNum][colNum];
Did you do the maths to find out how big this array really is?
I did - it's 18,662,400 bytes, if a short is 2 bytes on your machine.
> EarthCalc trialone(5);
This tries to create that massive array on the program stack.
Given that on most operating systems, the default stack size is between 1MB and 8MB, you're blowing that away with the very first thing you do.
Make your EarthCalc constructor allocate this array dynamically.
oh ok, so I am assuming i should make a pointer and reference to that array instead? I did that calculation already and know its 18MB, i just never knew that the stack size is only 1MB to 8 MB lol
Originally Posted by Salem
but thanks, Ill give it a shot and post back results