Problems with array of pointers
<p>I need to build an array of pointers to int, all by dynamic memory allocation.
I start with declaring:</p>

<pre><code>  int** queue = (int**)malloc(sizeof(int*));
</code></pre>

<p>and than (size =1)</p>

<pre><code>queue[*size-1] = (int*)calloc(1,sizeof(int));
</code></pre>

<p>I scan an integer:</p>

<pre><code>printf("Enter item value to add\n");
    scanf("%d",queue[*size-1]);
    printf("Item %d added\n",*(queue[*size-1]));
</code></pre>

<p>All these code is in the same function and works fine.
but when I try to print something from this queue in another function or to free the memory by:</p>

<pre><code>for(i = 0;i&lt;size;i++)
    {
        free(queue[i]);
    }
    free(queue);
</code></pre>

<p>the program crashes.
I would love for some help.
Thanks in advance!</p>