How do you delete an element of an array of pointers which is pointed at an allocation of memory on the heap?
inside a for loop, but it outputs the following message:Code:
So I guessed that syntax like that only deletes the element of the array of pointers itself, and not what that element is pointing at. So, next I tried:Quote:
memory clobbered before allocated block
thinking that by retrieving the address of the element of the array of pointers, I could then delete it. But it still outputs the same message. So I guess that using the address-of operator on an element of an array of pointers (or an element of any array) will only retrieve the address of the element, instead of what's stored in the pointer element.Code:
const char** pointer = &arrayOfPointers[i];