I believe your problem is in not using curly braces for your while-loops, in this statement:
1 2
while(pivot<myArray[right])
right--;
You decrement right until it's equal to pivot, which at that point is set to myArray[0]. Also, it will probably decrement it until it is equal to left, considering that left is the beginning of the array. So that's where your while(left!=right) will break and return right.
For some very good advice on pivot choice algorithms, please see: http://www.cplusplus.com/faq/sequences/sequencing/sort-algorithms/quicksort/#pivot-choice