title: Unable to dereference double pointer in c
body: <p>The output of this code is 20 20 10. The first 20 is easy to understand. But I am unable to understand how function <code>change1</code> and <code>change2</code> are accessing the variable b.</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  int a = 5, b = 10;
  void change1(int *p);
  void change2(int **pp);
  main( )
  {
      int x=20, *ptr=&amp;x;
      printf("%d  ",*ptr);
      change1(ptr);
      printf("%d  ",*ptr);
      change2(&amp;ptr);
      printf("%d\n",*ptr);
  }
  void change1(int *p)
  {
      p = &amp;a;
  }
  void change2(int **pp)
  {
      *pp = &amp;b;
  }
  </code></pre>