When we deallocate the heap memory occupied by an array, I have a little confusion regarding the syntax
int *p = new int[5];
Now for deallocating, which one is correct from the following:
delete p;
OR
delete[ ] p;
The latter seems to be more correct. But it confuses me, I don't understand that how would it know that how much memory the array exists on. I mean, we are only giving it the starting address of the array(through p). So, beginning from the starting address how will the compiler know that till where does it have to deallocate, and when to stop the deallocation.