MattWoberts
Programmer
Hi, I have this code which allocates a 2 dimensional array in C++:
This works fine, and does the job. But in my code to release the array, I get a bad memory error (DAMAGE: After normal block). This is my code that causes the error:
Any ideas? I'm a bit rusty on c++ so its stumped me!
Thanks.
Matt.
Code:
int subElements = 10;
int ** myArray;
myArray = (int **) new int*[lNumIntervals]; // Array of array pointers
for (lTmp=0; lTmp<lNumIntervals; lTmp++)
{
myArray[lTmp] = (int *) new int[subElements];
memset (myArray[lTmp],0,sizeof(int)*subElements);
}
This works fine, and does the job. But in my code to release the array, I get a bad memory error (DAMAGE: After normal block). This is my code that causes the error:
Code:
for (lTmp=0; lTmp<lNumIntervals; lTmp++)
{
delete [] myArray[lTmp];
}
delete [] myArray;
Any ideas? I'm a bit rusty on c++ so its stumped me!
Thanks.
Matt.