I get this error when I'm attempting to delete an array. I'm new to dynamic arrays, and from what I have learned, arrays must be deleted after use. I plan on using this in a function later on, so deleting the array is a must.
Here's the error message:
Debug Error!
HEAP CORRUPTION DETECTED: after Normal block (#154) at 0x007E55A0.
CRT detected that the application wrote to memory after the end of heap buffer.
I know it must be something stupid that I did, but I have very limited knowledge on dynamic arrays.
I fixed size2 to be initialized to one, but it still is giving me the error. Do I need to change the other similar variables to one as well? Like size, init, and num?
Increasing size2 in your loop is not going to increase the amount of memory you allocated, so you trample all over memory you don't own, corrupting the heap. If you allocate room for 1 int in the array, you may store 1 int and no more.