title: Finding Convex Hull in C
body: <p>I want to get the convex hull of an array of points in C. I have a struct:</p>
  
  <pre><code>struct points{
  int i;
  int x;
  int y;
  };
  </code></pre>
  
  <p>where <code>i</code> is the label, <code>x</code> and <code>y</code> are the coordinates.</p>
  
  <p>I created an array of struct. Then I sorted it in increasing x-values and increasing y=values. Now, I made a linked list implemented as a stack. When the 3 points make a non-right turn, I would pop the point. and then push the next point in the array. But I can't do it correctly. </p>
  
  <p>Here's my code.</p>
  
  <pre><code>struct node* top = NULL;
  for (a = 0; a &lt;= sizeof(pt); a++){
                      for (b = a + 1; b &lt;= sizeof(pt); b++){
                          for (j= b+1; j &lt;= sizeof(pt); j++){                         
                              if(((pt[b].x - pt[a].x)*(pt[j].y - pt[a].y) - (pt[b].y - pt[a].y)*(pt[j].x - pt[a].x)) &gt; 0){
                                  top = pop(top, &amp;pt[b].i);                               
                              }
                              else {
                                  top = push(top, pt[j].i);                   
                              }
  
                          }
                      }
  
                  }
  </code></pre>
  
  <p>pt is the name of my struct array. Please help. </p>