title: Passing an array as an argument to a function in C
body: <p>I wrote a function containing array as argument,
  and call it by passing value of array as follows.</p>
  <pre><code>void arraytest(int a[])
  {
      // changed the array a
      a[0] = a[0] + a[1];
      a[1] = a[0] - a[1];
      a[0] = a[0] - a[1];
  }
  
  void main()
  {
      int arr[] = {1, 2};
      printf(&quot;%d \t %d&quot;, arr[0], arr[1]);
      arraytest(arr);
      printf(&quot;\n After calling fun arr contains: %d\t %d&quot;, arr[0], arr[1]);
  }
  </code></pre>
  <p>What I found is though I am calling <code>arraytest()</code> function by passing values, the original copy of <code>int arr[]</code> is changed.</p>
  <p>Can you please explain why?</p>