title: Recursive QuickSort in C
body: <p>I am confused why my recursive quicksort function isn't working.</p>
  
  <p>Here is the original function call:</p>
  
  <pre><code>qSort(quickArr,0,inCount-1,&amp;qSwapCount); 
  </code></pre>
  
  <p>where inCount-1 is the position of the final array element</p>
  
  <p>Here is the recursive quicksort function:</p>
  
  <pre><code>void qSort(int *qArr, int left, int right, int *qCount)
  {
    if(left&lt;right)
      {
        int pivotIndex=(left+right)/2;
        int pivot=partition(qArr, left, right, pivotIndex, qCount);
        qSort(qArr, left, pivot-1, qCount);
        qSort(qArr, pivot+1,right, qCount);
      }
  }
  </code></pre>
  
  <p>And here is the pivot function</p>
  
  <pre><code>int partition(int *qArr, int left, int right, int pivot, int *qCount)
  {
  
    int i;
    int pivotValue=qArr[pivot];
    int index=left;
  
    swap(&amp;qArr[pivot],&amp;qArr[right]);
    (*qCount)++;
  
    for(i=left;i&lt;right;i++);
    {
      if (qArr[i]&lt;pivotValue)
        {
      swap(&amp;qArr[i],&amp;qArr[index]);
      (*qCount)++;
      index++;
        }
    }
    swap(&amp;qArr[index],&amp;qArr[right]);
    return index;
  }
  </code></pre>
  
  <p>The sort must work in place, following closely to the pseudo-code provided on:
  <a href="http://en.wikipedia.org/wiki/Quicksort" rel="nofollow">http://en.wikipedia.org/wiki/Quicksort</a></p>
  
  <p>Thanks for your help!</p>
  
  <p>Here is my output:
  190 506 115 471 168 229 851 497 728 549 33 435 214 439 822 500 797 692 44 731 222 613 550 669 556 978 756 402 751 357 102 393 298 604 706 686 899 997 268 758 684 147 151 814 262 310 959 82 234 119 976 13 709 27 989 375 150 639 65 552 252 542 925 637 273 2 655 827 584 418 163 871 485 982 331 810 894 201 620 123 853 231 870 335 774 546 775 351 116 73 </p>
  
  <p>Obviously unsorted still :-D</p>