title: How do I pass a array of structures to a function as a pointer in C?
body: <p>I have done the following program, to input a graph and color it in at most 6 colors (given degree at most 5 etc.)</p>
  <p>Most of the code is self explanatory, with comments to explain what each line does.</p>
  <p>I have included my code below and the errors that are raised, but I'm especially curious whats causing the warning saying the parameter I've input isn't of expected type. This has become sort of a recurring error for me, and I'd love some feedback!</p>
  <p>Any suggestions on the code itself would be appreciated too, but my main issue at the moment is related to the passing of parameters</p>
  <pre><code>struct NODE{
      int node_no;
      char color;
  };
  
  char Colors[6]={'a','b','c','d','e','f'};
  
  // l-&gt;left index, right index is fixed at n-1, as we colors from  0 to n-1
  void ColorTree(struct NODE *Tree[], int l, int n, int Edges [][2], int e)
  {
      if(n==1)    // if only one node, color node with lowest color
      {
          Tree[0]-&gt;color='a';
      }
      
      int i,j; char used_colors[6], c='N';
      
      for(i=0;i&lt;=e;i++)   // colors 
      {
          if(Edges[i][0] == Tree[l]-&gt;node_no)
          {
              c=Tree[Edges[i][1]]-&gt;color;
              continue;
          }
          if(Edges[i][1] == Tree[l]-&gt;node_no)
          {
              c=Tree[Edges[i][0]]-&gt;color;
          }
  
          for(j=0;used_colors[j]!='\0';j++);  // finds empty position of used_colors
          if(c!='N')
              used_colors[j]=c;   // if the color is not N, add to already used colors
      }
  
      for(i=0;Colors[i]!='\0';i++)
          for(j=0;used_colors[j]!='\0';j++)
          {   
              if(Colors[i]==used_colors[j])   // the color is already used
                  continue;
              else if(used_colors[j+1]=='\0')     // the color is not used
                  break;
          }
  
      Tree[l]-&gt;color=Colors[i];   // the unused color being assigned to Tree[l]
  
      if(l==(n-1))    // all nodes have been colored
          return;
  
      ColorTree(&amp;Tree,l+1,(n-1),Edges, e);
  }
  
  int main()
  {     
      int n,e,i;
  
      scanf(&quot;%d&quot;, &amp;n);
      struct NODE Tree[n];    // n-&gt; no. of vertices 
  
      for(i=0;i&lt;n;i++)     // initialising the tree, with node 0,1,2...n-1 and  color = 'N'
      {
          Tree[i].node_no=i;
          Tree[i].color='N';    // 'N'-&gt;no color
      }
  
      scanf(&quot;%d&quot;, &amp;e);    // e-&gt; no.of edges
  
      int Edges[e][2];
      
      for(i=0;i&lt;e;i++)    // entering the edges
      {
          scanf(&quot;%d&quot;, &amp;Edges[i][0]);
          scanf(&quot;%d&quot;, &amp;Edges[i][1]);
      }
  
      ColorTree(&amp;Tree,0,(n-1),Edges,e);
  
      printf(&quot;%c&quot;, Tree[0].color);    // printing the colors in the graph
      for(i=1;i&lt;n;i++)
          printf(&quot;\n%c&quot;, Tree[i].color);
      
      return 0;
  }
  </code></pre>
  <p>The errors i'm getting are:</p>
  <pre><code>&lt;file_name&gt;.c:51:15: warning: passing argument 1 of ‘ColorTree’ from incompatible pointer type [-Wincompatible-pointer-types]
     51 |     ColorTree(&amp;Tree,l+1,(n-1),Edges, e);
        |               ^~~~~
        |               |
        |               struct NODE ***
  &lt;file_name&gt;.c:11:29: note: expected ‘struct NODE **’ but argument is of type ‘struct NODE ***’
     11 | void ColorTree(struct NODE *Tree[], int l, int n, int Edges [][2], int e)
        |                ~~~~~~~~~~~~~^~~~~~
  &lt;file_name&gt;.c: In function ‘main’:
  &lt;file_name&gt;.c:77:15: warning: passing argument 1 of ‘ColorTree’ from incompatible pointer type [-Wincompatible-pointer-types]
     77 |     ColorTree(&amp;Tree,0,(n-1),Edges,e);
        |               ^~~~~
        |               |
        |               struct NODE (*)[(sizetype)(n)]
  &lt;file_name&gt;.c:11:29: note: expected ‘struct NODE **’ but argument is of type ‘struct NODE (*)[(sizetype)(n)]’
     11 | void ColorTree(struct NODE *Tree[], int l, int n, int Edges [][2], int e)
        |   
  </code></pre>
  <p>My program eventually terminates through Segmentation fault after the inputs.
  What am I doing wrong in passing the array of structures as reference?</p>