Modify pointer value in a function
<p>I'm studying pointers and i'm trying to understand this code. </p>

<pre><code>int main()
{
    int i=66 ;
    int *x;
    x=&amp;i;
    f(&amp;x);
    printf("%d",*x);

    return 0;

}
void f(int *x)
{
    int j=7;
    x=&amp;j;
    printf("%d-",*x);

} 
</code></pre>

<p>I'm expectin as output : 7-7 , but i get 7-66. I suppose that when i write </p>

<blockquote>
  <p>x=&j; </p>
</blockquote>

<p>in the function the original pointer now is setted to the direction of the j value and this is ok because the printf return 7- but why when i go  back to the main the printf return 66? isn't the pointer now setted to the j value of the function ? i know the values in the function are lost when i close the function but why my pointer is still setted to the i value in the main after i run the function?</p>