C++ Bubble Sort with offset?
<p>First of all, this is a homework assignment. I'm trying to make some bubbleSort function in C++ with an offset. The function must take an array input with an offset with count elements.</p>

<p>For example: <code>a[5] = {90, 9, 2, 10, 5}</code> -> <code>bubbleSort(a, 1, 4)</code> -> <code>{90, 2, 5, 9, 10}</code></p>

<p>Currently here is what my code looks like :</p>

<pre><code>void bubbleSort(int arr[], int offset, int count) {
    bool swapped = true;
    int pivot = offset;
    while (swapped) {
        swapped = false;
        pivot++;
            for (offset ; offset &lt; count - pivot; offset ++) {
                if (arr[offset] &gt; arr[offset+1]) {
                    arr[offset] ^= arr[offset+1];
                    arr[offset+1] ^= arr[offset];
                    arr[offset] ^= arr[offset+1];
                    swapped = true;
                }
            }
    }
}
</code></pre>

<p>I think my offset checking is off the index, could you please tell me where I've gone wrong?</p>
