title: Unable to return a type struct in C
body: <p>I have the following struct and function. After allocating a 2D array, I want to return it but for some reason I keep getting the error: &quot;warning: returning ‘int **’ from a function with incompatible return type ‘Array *’ {aka ‘struct array *’} [-Wincompatible-pointer-types]&quot;</p>
  <pre><code>typedef struct array
  {
      int n1;
      int n2;
      int *data;
  } Array;
  
  
      Array *array_create(int n1, int n2)
      {
      
       int **arr = malloc(n1 * sizeof(int*));
        for (int i = 0; i &lt; n1; i++)
        {
         arr[i] = malloc(n2*sizeof(int));
        }
      
        Array values = {n1, n2, *arr};
      
          return values;
      }
  </code></pre>
  <p>Here's some code from the main function for some clarity:</p>
  <pre><code>{
      Array *arr = array_create(4, 4);
  
      int cnt = 1;
      for (int i = 0; i &lt; 4; i++) {
          for (int j = 0; j &lt; 4; j++) {
              array_set(arr, i, j, cnt++);
          }
      }
  </code></pre>