title: K&R Qsort example with Pointers and Arrays confusion
body: <p>I find it difficult to understand the following snippet of code.  I understand the pointer to function mannerism showed, but where I find confusion is in the indicated lines.</p>
  
  <pre><code>void qsort(void **v, int left, int right, int (*comp) (void *, void *))
  {
      int i, last;
      void swap(int **v, int i, int j);
  
      if (left &gt;= right)   /* do nothing if array contains */
          return;           /* fewer than two elements */
      swap(v, left, (left + right)/2);   /* move partition elem */ [1]
      last = left;                       /* to v[0] */ [2]
      for (i = left + 1; i &lt;= right; i++) /* partition */ [3]
          if ((*comp) (v[i], v[left]) &lt; 0) [4]
              swap(v, ++last, i); [5]
      swap(v, left, last);        /* restore partition elem */ [6]
      qsort(v, left, last - 1); [7]
      qsort(v, last + 1, right);  [8]
  
  }
  </code></pre>
  
  <p>Can someone explain this routine to me, especially the indicated lines, just tell me what it's doing, because I can't figure this qsort out, the eskimo guide I read whilst reading k&amp;r said that the qsort routine is rubbish, and overly complicated. I just need to understand why it's written like this, because it makes no sense to me.</p>
  
  <p>Thanks, if for nothing, for reading this.</p>