title: Recursive quick-sort causing segmentation fault (not overflow)
body: <p>Please help me (this would be very handy for a school project due tommorow)</p>
  
  <p>I haven been trying to implement a recursive quick-sort algorithm in C++, however, when i run it i get a runtime segmentation fault(windows):</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;sstream&gt;
  #include &lt;stdlib.h&gt;
  
  using namespace std;
  
  void getRandomList(int, int*);
  void outputList(int, int*);
  void quicksort(int, int*);
  
  int main()
  {
      cout&lt;&lt;"Quick Sort example, By Jack Wilkie\n";
      while (true)
      {
          cout&lt;&lt;"Please enter list length\n";
          string pnput;
          cin&gt;&gt;pnput;
          cin.ignore(1);
          stringstream temp;
          temp &lt;&lt; pnput;
          int length;
          temp &gt;&gt; length;
          if (length &lt; 1 || length &gt; 100000)
          {
              cout&lt;&lt;"INVALID INPUT! (0 &lt; input &lt; 100,000)\n";
          }
          else
          {
              cout&lt;&lt;"Creating random list of "&lt;&lt;length&lt;&lt;" items\n";
              int *list = new int[length];
              getRandomList(length, list);
              outputList(length, list);
              double start = clock();
              quicksort(length, list);
              double stop = clock();
              double time = stop-start;
              cout&lt;&lt;time&lt;&lt;"ms";
              cin.get();
              delete[] list;
              break;
          }
      }
  }
  
  void quicksort(int len, int* list)
  {
      if (len &lt; 1)
      {
          return;
      }
      else
      {
          int low[10];
          int mid[10];
          lmid[0] = list[0];
          int high[10];
          int lens[3] = {0,1,0};
          for(int i = 1; i &lt; len; i++)
          {
              if(list[i] &lt; list[0])
              {
                  low[lens[0]] = list[i];
                  lens[0]++;
              }
              else if (list[i] &gt; list[0])
              {
  
                  high[lens[2]] = list[i];
                  lens[2]++;
              }
              else
              {
                  mid[lens[1]] = list[i];  
                  lens[1]++;
              }
          }
          quicksort(lens[0], low);
          quicksort(lens[2], high);
          for(int i = 0; i &lt; len; i++)
          {
                  if (i &lt; lens[0])
                  {
                        list[i] = low[i];
                  }
                  else if (i &lt; lens[0]+lens[1])
                  {
                         list[i] = mid[i-lens[0]];
                  }
                  else
                  {
                      list[i] = high[i-lens[0]-lens[1]];
                  }
          }
      }
      return;
  
  }
  </code></pre>
  
  <p>My debug program (dev c++, almost out of internet and cant get anything big) say that the error is on line</p>
  
  <pre><code>    lmid[0] = list[0];
  </code></pre>
  
  <p>however i cannot find any issues with it, it has the error as soon as it calls the quicksort function, i beleive the issue has something to do with passing an array, and i am fairly sure that the function isn't recursing and bloating the stack</p>
  
  <p>in case you need it for debuging, here are the other functions i used</p>
  
  <pre><code>void getRandomList(int length, int* output)
  {
      for(int i = 0; i &lt; length; i++)
      {
          output[i] = rand() % 100;
      }
      return;
  }
  
  void outputList(int length, int* input)
  {
      for(int i = 0; i &lt; length; i++)
      {
          cout&lt;&lt;input[i]&lt;&lt;" ";
      }
      cout&lt;&lt;"\n";
      return;
  }
  </code></pre>