title: As i have read local variable declared in side a func gets destroyed once the func finishes execution. Then how This code is working
body: <pre><code>#include &lt;stdio.h&gt;
  void foo(int **p)
  {
   int j=2;
   *p=&amp;j;
   printf(&quot;%d  \n&quot;,**p );
  
  }
  int main()
  {
   int i=97 ;
   int *p=&amp;i;
   foo(&amp;p);
   printf(&quot;%d \n&quot;,*p );
   return 0;
  }
  </code></pre>
  <p><strong>According to definition :A local variable is destroyed at the moment that the program execution reaches the end of the method in which the local variable is defined</strong>
  Then how in main() func it is still able to print 2. If int j=2; is already destroyed?
  <strong>Is it like the variables gets destroyed but it is still accessible by addresses?I know this is call by reference</strong></p>