Confusion in syntax related to Deallocating Heap Arrays : <p>When we deallocate the heap memory occupied by an array, I have a little confusion regarding the syntax</p>

<pre><code>int *p = new int[5];
</code></pre>

<p>Now for deallocating, which one is correct from the following:</p>

<pre><code>delete p;
</code></pre>

<p>OR</p>

<pre><code>delete[ ] p;
</code></pre>

<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.</p>
