title: Swap two strings in C++
body: <p>I have to swap two strings. This is my code:</p>
  
  <pre><code>void swap(char *x, char *y) {
      char tmp;
      tmp = *x;
      *x = *y;
      *y = tmp;
  }
  
  char a[20] = "car";
  char b[20] = "hotel";
  
  swap(a, b);
  </code></pre>
  
  <p>The program returns har - cotel. Why?</p>
  
  <p>Where is the error? I need hotel - car.</p>