title: Why can't I copy an array by using `=`?
body: <p>I'm starting to learn C by reading K&amp;R and going through some of the exercises.  After some struggling, I was finally able to complete exercise 1-19 with the code below:</p>
  
  <pre><code>/* reverse: reverse the character string s */
  void reverse(char s[], int slen)
  {
    char tmp[slen];
    int i, j;
  
    i = 0;
    j = slen - 2;    /* skip '\0' and \n */
  
    tmp[i] = s[j];
    while (i &lt;= slen) {
      ++i;
      --j;
      tmp[i] = s[j];
    }
  
    /* code from copy function p 29 */
    i = 0;
    while ((s[i] = tmp[i]) != '\0')
      ++i;
  
  }
  </code></pre>
  
  <p>My question is regarding that last bit of code where the <code>tmp</code> char array is copied to <code>s</code>.  Why doesn't a simple <code>s = tmp;</code> work instead?  Why does one have to iterate through the array copying index by index?</p>