title: Swapping pointers in C (char, int)
body: <p>I have been struggling to understand the different behaviour when swapping pointers in C.
  If I want to swap two <code>int</code> pointers, then I can do</p>
  
  <pre><code>void intSwap (int *pa, int *pb){
      int temp = *pa;
      *pa = *pb;
      *pb = temp;
  }
  </code></pre>
  
  <p>However, if I want to swap two <code>char</code> pointers I need to do something like</p>
  
  <pre><code>void charSwap(char** a, char** b){
      char *temp = *a;
      *a = *b;
      *b = temp;
  }
  </code></pre>
  
  <p>because if I do </p>
  
  <pre><code>void charSwap(char* a, char* b){
      char temp = *a;
      *a = *b;
      *b = temp;
  }
  </code></pre>
  
  <p>the compiler complains about the expression *a = *b as it cannot change the values.
  If I want to swap two <code>strings</code> (i.e. <code>char* s1= "Hello"; char* s2="Bye";</code> )how would one do it?</p>
  
  <p>Could you please give me a little bit of help? I would like to really learn how it works so I will not need to experience trial and error all the time until I get the right answer.
  I hope it's useful for many other people.</p>