title: Abort trap in C without any understandable reason (for me ;))
body: <p>The following code compiles without any problem with the command 'gcc -lm':</p>
  
  <pre><code>/*  The code was considerable shortened for a clearer understanding     */
  
  #include &lt;stdio.h&gt; 
  #include &lt;stdlib.h&gt; 
  #include &lt;math.h&gt;
  #include &lt;string.h&gt; 
  #include &lt;complex.h&gt;
  
  #define N       (21)            /*  Number of positions of the chain        */
  
  double Tleft, Tright, gama, J, k, Ji, C, omega;
  
  
  void rk4(double h, complex a[N], complex da[N], double b[N],double db[N],double c[N], double dc[N])
  {;}
  
  int main()
  {
      double tmax, dt;                //max time and lenth of the step
      double xn[N], dxn[N], pn[N], dpn[N];
      complex alfan[N], dalfan[N];
      double tempo;
      char fileName[100];         
      FILE *outputFile;
      int i, j;
      int printEvery;
  
  
      //Asking for input
  
      printf("tmax = ");              //These variables are either used in main() or in rk4()
      scanf("%lf", &amp;tmax);
      printf("%f\n", tmax);
      printf("dt = ");
      scanf("%lf", &amp;dt);
      printf("%f\n", dt);
      printf("Tleft = ");
      scanf("%lf", &amp;Tleft);
      printf("%f\n", Tleft);
      printf("Tright = ");
      scanf("%lf", &amp;Tright);
      printf("%f\n", Tright);
      printf("gamma = ");
      scanf("%lf", &amp;gama);
      printf("%f\n", gama);
      printf("J = ");
      scanf("%lf", &amp;J);
      printf("%f\n", J);
      printf("k = ");
      scanf("%lf", &amp;k);
      printf("%f\n", k);
      printf("Ji = ");
      scanf("%lf", &amp;Ji);
      printf("%f\n", Ji);
      printf("C = ");
      scanf("%lf", &amp;C);
      printf("%f\n", C);
      printf("omega = ");
      scanf("%lf", &amp;omega);
      printf("%f\n", omega);
      printf("print every ");
      scanf("%d", &amp;printEvery);
      printf("%d\n", printEvery);
  printf("Print this");
  
      for (i = 1; i&lt;=N; i++)          //Initializing vectors
      {
          alfan[i] = 0.0+0.0i;
          dalfan[i] = 0.0+0.0i;
          xn[i] = 0.0;
          dxn[i] = 0.0;
          pn[i] = 0.0;
          dpn[i] = 0.0;
      }
  
      tempo = 0.0;                    //Initializing time
  
      //Initializing the file and printing its column titles
  
      sprintf(fileName, "tmax=%.4f, dt=%.4f, Tleft=%.4f, Tright=%.4f, gamma=%.4f, J=%.4f, k=%.4f, Ji=%.4f, C=%.4f, omega=%.4f, every%d.dat", tmax, dt, Tleft, Tright, gama, J, k, Ji, C, omega, printEvery);
      outputFile = fopen(fileName, "w");
      fprintf(outputFile, "tempo\t\t");
      for (i = 1; i&lt;=N; i++)                              //alfas
      {
          fprintf(outputFile, "realfa[%d]\timalfa[%d]\t", i, i);
      }
      for (i = 1; i&lt;=N; i++)                              //x's
      {
          fprintf(outputFile, "x[%d]\t\t", i);
      }
      for (i = 1; i&lt;=N-1; i++)                            //p's
      {
          fprintf(outputFile, "p[%d]\t\t", i);
      }
      fprintf(outputFile, "p[%d]\n\n", i);
  
      j = 0;
  
      while (tempo &lt; tmax)            
      {
          if (j % imprimirCada == 0)
          {
              fprintf(outputFile, "%f\t", tempo);                     //tempo
              for (i = 1; i&lt;=N; i++)                          //alfas
              {
                  fprintf(outputFile, "%f\t%f\t", creal(alfan[i]), cimag(alfan[i]));
              }
              for (i = 1; i&lt;=N; i++)                          //x's
              {
                  fprintf(outputFile, "%f\t", xn[i]);
              }
              for (i = 1; i&lt;=N-1; i++)                        //p's
              {
                  fprintf(outputFile, "%f\t", pn[i]);
              }
              fprintf(outputFile, "%f\n", pn[i]);
  
          }
  
          j++;
          rk4(dt, alfan, dalfan, xn, dxn, pn, dpn);
          tempo += dt;
      }
  
      printf("\n");
  
      return 0;       
  }
  </code></pre>
  
  <p>When I run it, I obtain:</p>
  
  <pre><code>tmax = 1 
  1.000000
  dt = 0.1
  0.100000
  Tleft = 0.1
  0.100000
  Tright = 0.2
  0.200000
  gamma = 0.5
  0.500000
  J = 0.001
  0.001000
  k = 0.001
  0.001000
  Ji = 0.001
  0.001000
  C = 0.001
  0.001000
  omega = 0.01
  0.010000
  print every 1
  1
  Abort trap
  </code></pre>
  
  <p>What causes the 'Abort trap' and why don't I obtain the last 'printf("Print this")' sentence?</p>
  
  <p>Thank you for your help!!</p>