title: Why is this array not big enough?
body: <p>I have been running this random walk simulation for a while now and I keep getting an error <code>EXC_BAD_ACCESS</code> from Xcode. Its printing out a large part of the simulation though.</p>
  
  <p>I think its running out of memory for some reason but I am not sure why.  </p>
  
  <p>If I go towards the end of the array I edited it so I don't get within 100 spaces of the edge (by editing the variable steps to steps -100). This works but I would like to know whats going on. </p>
  
  <p>Any help would be appreciated. </p>
  
  <pre><code>double** places;  
  places = (double**) malloc(steps*sizeof(double*));  
  for (int i = 0; i &lt; steps; i++)places[i] = (double*) malloc(2*sizeof(double));  
  
  for (i = 0; i&lt; steps/*, exit*/; i++) {
      // Find the angle of movement 
      angle = getRand()*360; 
      // Take a step
      xPos+= STEP*cos(angle);
      yPos+= STEP*sin(angle);
      //Write Step to array
      places[i][1] = xPos;
      places[i][2] = yPos;
      //Write Step to File
      fprintf(ff, "%d %lf %lf\n",i,xPos,yPos);
  }
  </code></pre>