title: Passing 1D array, 2D arrays and pointer Arrays
body: <p>To pass a 1D array to a function, we do this:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  void func(int *arr, int n)
  {
      // code here
  
  }
  
  int main()
  {
      int arr[] = {......};                   // declare array
      int n = sizeof(arr)/sizeof(arr[0]);
      func(arr);                              // calling function func
  
      return 0;
  }
  </code></pre>
  
  <p>To pass a 2D array to a function, we do this: </p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  void func(int arr[][2])
  {
      // code here
      }
  
  int main()
  {
      int arr[3][2];  // declare 2D array
      func(arr);      // calling function func
  
      return 0;
  }
  </code></pre>
  
  <p>So while passing a pointer array to a function, can we do something like this?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  void func(int **arr, int n)
  {
      // code here
  
  }
  
  int main()
  {
      int *arr[] = {......};                // declare array of pointers
      int n = sizeof(arr)/sizeof(arr[0]);
      func(arr, n);                           // calling function func
  
      return 0;
  }
  </code></pre>
  
  <p>I am confused with pointers and arrays to be honest. It took me a long time to figure out how to pass a 2D array. I tried searching other similar questions, but to no avail. Please help me with: Passing a pointer array to a function. Also, any links where I can clear the confusion will be really appreciated.</p>