C : In function, malloc two dimensional array and duplicatating array of argument does not work : <pre><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;

int** asd(int map[][7]);

int main(void)
{
    int **child_map = (int**)malloc(sizeof(int*) * 6);
    int i, k;
    for (i = 0; i &lt; 6; i++)
        child_map[i] = (int*)malloc(sizeof(int) * 7);


    for (i = 0; i &lt; 6; i++)
    {
        for (k = 0; k &lt; 7; k++)
        {
            child_map[i][k] = 10;
        }
    }

    for (i = 0; i &lt; 6; i++)
    {
        for (k = 0; k &lt; 7; k++)
        {
            printf("%3d", child_map[i][k]);
        }
        printf("\n");
    }

    int **map = NULL;
    map = asd(child_map);

    for (i = 0; i &lt; 6; i++)
    {
        for (k = 0; k &lt; 7; k++)
        {
            printf("%3d", map[i][k]);
        }
        printf("\n");
    }

    return 0;
}

int** asd(int map[][7])
{
    int **a = (int**)malloc(sizeof(int*) * 6);
    int i, k;
    for (i = 0; i &lt; 6; i++)
        a[i] = (int*)malloc(sizeof(int) * 7);


    for (i = 0; i &lt; 6; i++)
    {
        for (k = 0; k &lt; 7; k++)
        {
            a[i][k] = map[i][k];
        }
    }
    return a;
}
</code></pre>

<p>In function, a[i][k] and map[i][k] are not mapped. Value of array a is very strange like 99882978. Why doesn't it work?<br>
I have been made tree of game like go and each tree node has copy of parent's map. So i made function malloc two dimesional array , copies map of parent and return pointer of copy map. But it do not work... 
I'm very stuck here...</p>
