Quicksort using pointers As an exercise, I've written quicksort algorithm in C using pointers. Please comment and help me find the cases where it breaks (if any).

void qsort(int *, int, int);
void swap(int *, int *);

void qsort(int *v, int left, int right)
{
    int i, *last;

    if (right &lt;= left)
        return;
    last = v + left; //choosing the first element as the pivot
    for (i = left + 1; i &lt;= right; i++)
        if (*(v + i) &lt; *(v + left))
            swap(++last, v + i); //swapping the numbers &lt; pivot
    swap(v + left, last);
    qsort(v, left, last - v - 1); //sub-array containing numbers &lt; pivot
    qsort(v, last - v + 1, right); //sub-array containing numbers &gt;= pivot
}

void swap(int *i, int *j)
{
    int temp;

    temp = *i;
    *i = *j;
    *j = temp;
}
I'd make right an exclusive instead of inclusive upper bound, that is write i &lt; right instead of i &lt;= right and last - v instead of last - v - 1.

This has the advantage of making the base call qsort(v, 0, length) instead of qsort(v, 0, length - 1).