title: passing array of structure pointer to a function
body: <p>I am writing a program in which I have to pass an array of structure pointers to a function in main body as follows</p>
  
  <pre><code>     struct node *vertices[20];
  create_vertices (&amp;vertices,20);
  </code></pre>
  
  <p>implementation of   function is some thing like this</p>
  
  <pre><code>void create_vertices (struct node *vertices[20],int index)
  {
  }
  </code></pre>
  
  <p>in this I have to pass an array of structure pointers with index 20, 
  the declaration I did outside mains is as follows I </p>
  
  <pre><code>void create_vertices(struct node **,int);
  </code></pre>
  
  <p>However each time compiling the code gives me problem in these three lines only as </p>
  
  <pre><code>bfs.c:26:6: error: conflicting types for ‘create_vertices’
  bfs.c:8:6: note: previous declaration of ‘create_vertices’ was here
  bfs.c: In function ‘create_vertices’:
  bfs.c:36:15: error: incompatible types when assigning to type ‘struct node’ from type ‘struct node *’
  </code></pre>
  
  <p>I am unable to understand how should I be doing this.
  What I want to be able to do is:</p>
  
  <ol>
  <li>Declare an array of structure pointers in main (which I already did).</li>
  <li>Pass the address of array to function (here is where I goofed up).</li>
  <li>Declare the correct prototype of function outside mains.  </li>
  </ol>
  
  <p>The code has to be on C and I am testing it on Linux.
  Can some one point me?</p>