Swapping strings : <p>Have written a routine to swap strings , the first routine fails where as the second routine correctly swaps . Need to know the reason for the same they seem to do the same thing not sure why the second one works perfectly not the first .</p>

<p><strong>First Method</strong> </p>

<pre><code>void swap(char *str1, char *str2)
{
  char *temp = str1;
  str1 = str2;
  str2 = temp;
}
</code></pre>

<p><strong>Second Method</strong> </p>

<pre><code>void swap(char **str1, char **str2)
{
  char *temp = *str1;
  *str1 = *str2;
  *str2 = temp;
}
</code></pre>
