title: What is wrong in passing pointer variable as an function argument instead of address of variable in C?
body: <p>I know that if I pass <strong>&amp;a</strong> as an argument in <strong>fun</strong> ,I will get result as *p =20 after <strong>fun</strong> is executed .Now see in the following code <strong>p</strong> is pointer variable passed as an argument to function <strong>fun</strong>. But after compilation I get result as *<strong>p =10 instead of 20</strong> .</p>
  <p>What is wrong in passing pointer variable <strong>p</strong> instead of address of a i.e. <strong>&amp;a</strong> to function <strong>fun</strong>?</p>
  <pre><code>#include &lt;stdio.h&gt;
  int a = 10, b = 20;
  void fun(int *p)
  {
      p = &amp;b;
  }
  int main()
  {
      int *p = &amp;a;
      fun(p);
     //fun(&amp;a);
  
      printf(&quot;%d\n&quot;, *p);
      return 0;
  }
  </code></pre>