title: for loop is crashing on big number
body: <p>I have a problem. I have to write a program that counts the collisions of a table of randomly generated numbers (collision test). For example the table [1,2,2,3,4,5,5,5,6] has 3 collisions. </p>
  
  <p>And my problem is that whenever i try to increase number <code>n</code> to for example <code>int n = 5191401;</code> my program crashes. What is happening? Why does it stop working? I need really big amount of random numbers (like 10^14).</p>
  
  <p>Here is my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;gsl/gsl_rng.h&gt;
  #include &lt;stdlib.h&gt;
  #include&lt;cmath&gt;
  
  using namespace std;
  
  int compare(const void * a, const void * b)
  {
      return ( *(int*)a - *(int*)b );
  }
  
  int main (void)
  {
      unsigned int seed=10540000;
      gsl_rng * r=gsl_rng_alloc (gsl_rng_minstd);
      gsl_rng_set(r,seed);
      gsl_rng_env_setup();
      int lPrzedzialow=400000000;
      int n = 519140;
      int z,lKolizji=0;
      int lwKomorkach[n-1];
      double dlPrzedzialu=1./(lPrzedzialow);
  
      for (int i = 0; i &lt; n; i++)
      {
          lwKomorkach[i]=floor(gsl_rng_uniform (r)/dlPrzedzialu)+1;
      }
  
      qsort (lwKomorkach, n, sizeof(int), compare);
  
      for(z=0;z&lt;=n-1;z++)
      {
          if(lwKomorkach[z+1]==lwKomorkach[z])
          {
              lKolizji++;
          }
      }
  
      cout&lt;&lt;endl&lt;&lt;lKolizji&lt;&lt;endl;
      gsl_rng_free (r);
  
      return 0;
  }
  </code></pre>