core dumped- dynamic arrays

hi!
im desperate...

i dont know why but in specific test that i run on my code the program crushed.
that heppens while the program releases the memory of 2d dynamic array.
i checked the program hundreds of times but I can not understand what the problem is.

I know that usually this happens when trying to reach memory that is not allocated but it is not the case.

this is a video that i uploaded that describes my problem:
https://www.youtube.com/watch?v=Qwxi6XNZo98

and this is the function that free the memmory:

1
2
3
4
5
6
7
8
9
10
 //===================================================================
//function that releases the memory in the end of the program
//------------------------------------------------------------------
void release_final(int **&arr,int limit)
{
 int loop=0;//looping variable
 for (loop=0;loop<limit;loop++)
      delete[] arr[loop];
 delete[] arr;
}




thanks.
Looks like you are deleting an item in the array and than the whole array on the first
execution of your loop. Than the loop keeps going and trying to delete more items from the array but the array has already been deleted.

Place delete[] arr; outside the loop.
But delete [] arr is already outside the loop.
There are no { } in the loop.
More than that, i run 10 tests but the problem is just in one test...
According to what you said the problem should be in all the tests...

Thanks.
change delete[] arr[loop]; to delete arr[ loop ]

and int **&arr to int **arr
Topic archived. No new replies allowed.