delete pointers created by new in CallBack Function
<p>I am doing the following:</p>

<pre><code>LRESURT CALLBACK WindowProc{
    .......
    Case VK_RETURN:
        int i;
        for ( i = 0; i &lt;1000; i++) {
            int  size = determinesize(i);
            int *pttest = new int[size];
            .....(some work)....
            delete[] pttest;
        }
     ........
}
</code></pre>

<p>But I got problem when <code>VK_RETURN</code> occurs. If I don't use <code>delete[] pttest</code>.</p>

<p>My question is that: Do I need to delete ptttest? When I search on google, almost everyone said that for each new, there must be a delete. Another question is that: if I put the for loop code for <code>VK_RETURN</code> in a function, say <code>void whenvkreturn()</code>, then do I need to delete pttest? Since any local variables are destroyed after returning, I guess the 1000 objects created in this loop will be deleted automatically, right? I don't know the stack very well, so some explanation I found is not clear for me.</p>

<p>=====</p>

<p>OK, there is a vector workaround. But when it is the case:</p>

<p><code>TCHAR *text = new text[size];</code></p>

<p>What I am supposed to do?</p>
