Returning pointer to array doesn't give expected output in c : <pre><code>#include &lt;stdio.h&gt;

int* createReverseArray(int *array, int size)
{
    int i;
    int newArray[size];
    for(i=size-1; i&gt;=0; i--)
    {
        newArray[i] = array[size-i-1];
    }

    return newArray;
}

int main(void) {

    int myArray[] = {1,2,3,5,1};
    int myArray2[] = {1,2,3,4,2,1};
    int i;

    int size = sizeof(myArray)/sizeof(int);
    printf("Size: %d\n", size);
    int* newArray = createReverseArray(myArray, size);

    for(i=0; i&lt;size; i++)
    {
        printf("%d, ", newArray[i]);
    }

    return 0;
}
</code></pre>

<p>I printed the array within the createReverseArray function and got the correct output, but when I return the pointer to the array and then try to print the results, I think it's printing pointers to each array spot? I'm not quite sure.</p>

<p>This returns:</p>

<p>Size: 5</p>

<p>12341002, 1, -10772231820, -1077231812, 1074400845,</p>
