title: C++ quick sort algorithm
body: <p>I'm not looking to copy a qsort algorithm. I'm practicing writing qsort and this is what I've come up with and I'm interested in what part of my code is wrong. Please don't tell me that this is homework cause I could just use the code in the link below. </p>
  
  <p>Reference: <a href="http://xoax.net/comp/sci/algorithms/Lesson4.php" rel="nofollow">http://xoax.net/comp/sci/algorithms/Lesson4.php</a></p>
  
  <p>When this runs I get this in the console:  </p>
  
  <pre><code>Program loaded.
  run
  [Switching to process 10738]
  Running…
  Current language:  auto; currently c++
  Program received signal:  “EXC_ARITHMETIC”.
  
  
  void myQSort(int min, int max, int* myArray)
      {
          // Initially find a random pivot
          int pivotIndex = rand() % max;
              int pivot = myArray[pivotIndex];
  
          int i = 0 , j = max-1;
  
          // Pointer to begining of array and one to the end
  
          int* begin = myArray;
          int* end = &amp;myArray[max-1];
  
          // While begin &lt; end 
          while( begin &lt; end )
          {
          // Find the lowest bound number to swap
              while( *begin &lt; pivot )
              {
                  begin++;
              }
              while( *end &gt; pivot ) 
              {
                  // Find the highest bound number to swap
                  end--;
              }
  
          // Do the swap
              swap(begin,end);
          }
          // Partition left
          myQSort(0, pivotIndex-1, myArray);
          // Partiion right
          myQSort(pivotIndex+1,max, myArray);
  
      }
  </code></pre>
  
  <p>EDIT--
  Code for Swap:</p>
  
  <pre><code>void swap(int* num, int* num2)
  {
      int temp = *num;
      *num = *num2;
      *num2 = temp;
  }
  </code></pre>