title: segmentation fault : 11
body: <p>I'm having a problem with some program, I have searched about segmentation faults, by I don't understand them quite well, the only thing I know is that presumably I am trying to access some memory I shouldn't. The problem is that I see my code and don't understand what I am doing wrong. </p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include&lt;math.h&gt;
  #include&lt;stdlib.h&gt;
  
  #define   lambda   2.0
  #define   g        1.0
  #define   Lx       100
  #define   F0       1.0
  #define   Tf       10
  #define   h       0.1
  #define   e       0.00001
  
  FILE   *file;
  
  double F[1000][1000000];
  
  void Inicio(double D[1000][1000000]) {
  int i;
  for (i=399; i&lt;600; i++) {
      D[i][0]=F0;
  }
  }
  
  void Iteration (double A[1000][1000000]) {
  long int i,k;
  for (i=1; i&lt;1000000; i++) {
      A[0][i]= A[0][i-1] + e/(h*h*h*h)*g*g*(A[2][i-1] - 4.0*A[1][i-1] + 6.0*A[0][i-1]-4.0*A[998][i-1] + A[997][i-1]) + 2.0*g*e/(h*h)*(A[1][i-1] - 2*A[0][i-1] + A[998][i-1]) + e*A[0][i-1]*(lambda-A[0][i-1]*A[0][i-1]);
      A[1][i]= A[1][i-1] + e/(h*h*h*h)*g*g*(A[3][i-1] - 4.0*A[2][i-1] + 6.0*A[1][i-1]-4.0*A[0][i-1] + A[998][i-1]) + 2.0*g*e/(h*h)*(A[2][i-1] - 2*A[1][i-1] + A[0][i-1]) + e*A[1][i-1]*(lambda-A[1][i-1]*A[1][i-1]);
      for (k=2; k&lt;997; k++) {
          A[k][i]= A[k][i-1] + e/(h*h*h*h)*g*g*(A[k+2][i-1] - 4.0*A[k+1][i-1] + 6.0*A[k][i-1]-4.0*A[k-1][i-1] + A[k-2][i-1]) + 2.0*g*e/(h*h)*(A[k+1][i-1] - 2*A[k][i-1] + A[k-1][i-1]) + e*A[k][i-1]*(lambda-A[k][i-1]*A[k][i-1]);
      }
      A[997][i] = A[997][i-1] + e/(h*h*h*h)*g*g*(A[0][i-1] - 4*A[998][i-1] + 6*A[997][i-1] - 4*A[996][i-1] + A[995][i-1]) + 2.0*g*e/(h*h)*(A[998][i-1] - 2*A[997][i-1] + A[996][i-1]) + e*A[997][i-1]*(lambda-A[997][i-1]*A[997][i-1]);
      A[998][i] = A[998][i-1] + e/(h*h*h*h)*g*g*(A[1][i-1] - 4*A[0][i-1] + 6*A[998][i-1] - 4*A[997][i-1] + A[996][i-1]) + 2.0*g*e/(h*h)*(A[0][i-1] - 2*A[998][i-1] + A[997][i-1]) + e*A[998][i-1]*(lambda-A[998][i-1]*A[998][i-1]);
      A[999][i]=A[0][i];
  }
  }
  
  main() {
  long int i,j;
  Inicio(F);
  Iteration(F);
  file = fopen("P1.txt","wt");
  for (i=0; i&lt;1000000; i++) {
      for (j=0; j&lt;1000; j++) {
          fprintf(file,"%lf \t %.4f \t %lf\n", 1.0*j/10.0, 1.0*i, F[j][i]);
      }
  }
  fclose(file);
  }
  </code></pre>
  
  <p>Thanks for your time. </p>