title: Array Assignment
body: <p>Let me explain with an example -</p>
  
  <pre><code>#include &lt;iostream&gt;
  
  void foo( int a[2], int b[2] ) // I understand that, compiler doesn't bother about the
                                 // array index and converts them to int *a, int *b
  {
      a = b ;  // At this point, how ever assignment operation is valid.
  
  }
  
  int main()
  {
      int a[] = { 1,2 };
      int b[] = { 3,4 };
  
      foo( a, b );
  
      a = b; // Why is this invalid here.
  
      return 0;
  }
  </code></pre>
  
  <p>Is it because, array decays to a pointer when passed to a function <code>foo(..)</code>, assignment operation is possible. And in <code>main</code>, is it because they are of type <code>int[]</code> which invalidates the assignment operation. Doesn't <code>a,b</code> in both the cases mean the same ? Thanks.</p>
  
  <p><strong>Edit 1:</strong></p>
  
  <p>When I do it in a function <code>foo</code>, it's assigning the <code>b's</code> starting element location to <code>a</code>. So, thinking in terms of it, what made the language developers not do the same in <code>main()</code>. Want to know the reason.</p>