C++: the fucntion collapses at the 4th element of the array
<p>Could you have a look at what I've faced: <a href="http://sdrv.ms/WgafvN" rel="nofollow">http://sdrv.ms/WgafvN</a></p>

<p>And another screenshot: <a href="http://sdrv.ms/UZIp6H" rel="nofollow">http://sdrv.ms/UZIp6H</a></p>

<p>The text of my function is:</p>

<pre><code>bool print_all_points(POINT** pointer)
{

    if (pointer == NULL||is_array_empty(pointer)) 
    {
        cout &lt;&lt; "The array of points is empty." &lt;&lt; endl &lt;&lt; endl;
        return false;
    }
    else
    {
        int n = _msize(pointer)/sizeof(pointer[0]);
        cout &lt;&lt; "The list of points: " &lt;&lt; endl&lt;&lt; endl;
        cout &lt;&lt; "id (x, y)" &lt;&lt; endl;
        cout &lt;&lt; "----------" &lt;&lt; endl;
        for (int i = 0; i &lt; n; i++)
        {
            cout &lt;&lt; (*pointer[i]).id &lt;&lt; " (" &lt;&lt; (*pointer[i]).x &lt;&lt; ", " &lt;&lt; (*pointer[i]).y &lt;&lt; ")" &lt;&lt; endl;      
        }
    }
    return true;
}
</code></pre>

<p>This function is expected to print out all the points in an array. My problem is that it perfectly prints the array of 3 points rather than that of 4 points. At the 4th point it bites the dust.</p>

<p>I can't catch what the trouble is.
From the picture it is visible that:
1. All 4 elements of the array are present.
2. It is correctly determined that there 4 of them.</p>

<p>What is the problem?
Could you give me a kick here? </p>

<p>ADDED LATER.</p>

<p>The function which calls this:</p>

<pre><code>POINT**  new_point(POINT** pointer, int occup)
{
    char x;
    char y;
    system("cls");
    cout &lt;&lt; "INPUT A NEW POINT" &lt;&lt; endl &lt;&lt; endl;
    cout &lt;&lt; "Input x: ";
    cin &gt;&gt; x;
    cout &lt;&lt; "Input y: ";
    cin &gt;&gt; y;
    size_t m;
    if (pointer != NULL)
    {
        m = _msize(pointer);
    }

    POINT * tmp_point = new POINT();
    (*tmp_point).id = occup;
    (*tmp_point).x = x-48;
    (*tmp_point).y = y-48;  

    POINT** pn = new POINT * [occup];
    int necessary_memory = occup * 4; // ???? 4 is the size of a pointer.
    if (occup !=1)
    {
        memcpy(pn, pointer, necessary_memory);      
    }
    POINT ** tmp = new POINT * [occup];
    pn[occup - 1] = tmp_point;
    memcpy(tmp, pn, occup * sizeof(POINT)); 
    delete[] pn;
    pn = tmp;   
    size_t n = _msize(pn);
    cout &lt;&lt; endl;
    print_all_points(pn);
    return pn;
}
</code></pre>
