title: C language: How is swapping pointers different from swapping the value pointed to?
body: <pre><code>int a=5; b=7;
  int *pa=&amp;a, *pb=&amp;b;
  </code></pre>
  
  <p>How is swapping the values of a and b different from swapping the values of the pointers i.e <code>pa</code> and <code>pb</code> (not <code>*pa</code> and <code>*pb</code>)? Is the result not same in both cases? </p>
  
  <p>When do we have to use pointer swapping than?</p>
  
  <p>I have an example in the book that uses pointer swapping with an array of strings i.e <code>char*</code>[]. This is done as a part of sorting mechanism. The swapping function carries out pointer swapping for the <code>char* []</code> type variable that stores the strings. I do not understand why the function swap is of form <code>void swap(char** , char**)</code>.</p>
  
  <p>I can't find any explanation for this elsewhere thus my question. </p>
  
  <p>:( How does <code>swap(int*&amp; a, int*&amp; b)</code> compare to <code>swap(char** a,char** b)</code>.</p>