Error with c++ Arrays and Memory -
i have been working on converting batch game created c++ further advancement, , have run numerous problems, 1 of array need nodematrix (world map). need 100 x 100 map 20 data values per meter.
int nodematrix[99][99][19]; but problem when try set null(or ungenerated) state of map, crashes (0xc0000005), added visual script prints current node being reset (it's slower though),
void emptydata(){ int temp_x = 0; int temp_y = 0; int temp_t = 0; do{ temp_y = 0; do{ temp_t = 0; do{ nodematrix[temp_x][temp_y][temp_t] = 0; //visual cout << temp_x << " " << temp_y << " " << temp_t << endl; temp_t ++; }while(temp_t <= 50); temp_y ++; }while(temp_y <= 99); temp_x ++; }while(temp_x <= 99); } it crashes @ 99 14 10 each time, (it starts @ 0 100 15 11), 16500 bites data?
anyway, memory allocation? cant figure out.
it sounds problem have allocated 99 99 19 array, rather 100 100 20 array. array declaration takes number of elements, not max index.
i'm not sure how got temp_y = 14 , temp_t = 10, seems confirmed fact crashes @ temp_x = 99.
if post actual error message more helpful.
it appears limited temp_t 50, rather 20, think typo. also, stylistic note, loops more common in c++, handle indexing you.
Comments
Post a Comment