Why does printf modify previous local variables? : <p>I tried to understand C behavior and found some weird things.
I debugged and found out that table values are correct until calling printf.
I create a void function to test whether it is a problem of scope but after calling this function the table values still remained correct.
I wonder now if printf delete previous local variables.</p>

<pre><code>#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
void invertTable(int** tableau,int size){
    int temp[size];
    for(int i = 0; i &lt; size; i++)
    {
        temp[i]=-1*tableau[0][i];
    }
    tableau[0]=temp;
}
void test(){

}
int main(int argc, char const *argv[])
{
    int* table=(int*)malloc(5*sizeof(int));
    table[0]=1;
    table[1]=2;
    table[2]=3;
    table[3]=4;
    table[4]=5;
    invertTable(&amp;table,5);
    test();
    for(int i = 0; i &lt; 5; i++)
    {
        //Here is the problem
        printf("\n %d \n",table[i]);
    }
    free(table);
    return 0;
}
</code></pre>

<p>Expected -1 -2 -3 -4 -5</p>

<p>Output:  -1 1962295758 1 1962550824 1962295741</p>
