title: In C, what is the difference between passing array as *arr and *arr[] to function?
body: <pre><code>#include &lt;stdio.h&gt;
  
  void test(int *arr, int n)
  {
      for(int i = 0; i &lt; n; ++i)
          printf("%d ", *(arr + i));
      printf("\n");
  }
  
  int main(void) {
  
      int a[10] = { 1,2,3,4,5,6,7,8,9,10};
  
      test(a,10);
  
      return 0;
  }
  </code></pre>
  
  <p>this gives the correct answer which is "<code>1 2 3 4 5 6 7 8 9 10</code>"
  but when I change first argument's type in <code>test</code> function to <code>*arr[]</code> it gives </p>
  
  <pre><code>1 3 5 7 9 0 0 965108401 262144 404875544 
  </code></pre>
  
  <p>looks like <code>i += 2</code> happens in <code>for</code> loop.</p>
  
  <p>The changed code is below</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  void test(int *arr[], int n)
  {
      for(int i = 0; i &lt; n; ++i)
          printf("%d ", *(arr + i));
      printf("\n");
  }
  
  int main(void) {
  
      int a[10] = { 1,2,3,4,5,6,7,8,9,10};
  
      test(a,10);
  
      return 0;
  }
  </code></pre>
  
  <p>What <code>*arr[]</code> actually is?</p>