title: why does pointer get its previous value returning from a function
body: <p>guys how does the ptr get its previous value? code is simple, I just wondered why it doesn't store the address value that it's been assigned within the function.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;stdlib.h&gt;
  void test(int*);
  int main( )
  {
      int temp;
      int*ptr;   
      temp=3;
      ptr = &amp;temp;
      test(ptr);
  
  
      printf("\nvalue of the pointed memory after exiting from the function:%d\n",*ptr);
      printf("\nvalue of the pointer after exiting from the function:%d\n",ptr);
  
  
  system("pause ");
  return 0;
  } 
  
  
  void test(int *tes){
  
      int temp2;        
      temp2=710;
      tes =&amp;temp2;
  
      printf("\nvalue of the pointed memory inside the function%d\n",*tes);
      printf("\nvalue of the pointer inside the function%d\n",tes);
  
  
  }
  </code></pre>
  
  <p>output is:</p>
  
  <p>value of the pointed memory inside the function:<strong>710</strong></p>
  
  <p>value of the pointer inside the function:<strong>3405940</strong></p>
  
  <p>value of the pointed memory after exiting from the function:<strong>3</strong></p>
  
  <p>value of the pointer after exiting from the function:<strong>3406180</strong></p>