Why don't static arrays need to be freed?
<p>I am wondering why static arrays don't need to be freed? I know that when creating a dynamic array e.g. </p>

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

<p>we have to free the allocated memory by using:</p>

<pre><code>free(p);
</code></pre>

<p>And for a static array in a function, the static array will be automatically freed when the called function is done. </p>

<p>What I do not understand is: when returning a static array using a function like this:</p>

<pre><code>int *subFunc(){
    static int a[5] = {1,2,3,4,5};
    return a;
}

int main(){
    int *p;
    p = subFunc();
}
</code></pre>

<p>If the static array is automatically freed after completing the execution, then how can we still access the values of the static array correctly?</p>