I don't understand why this code returns segmentation fault. Can anybody help me telling what's wrong?
#include <stdio.h>
#include "rk78.h"
#include "flux.h"
#include "rtbps.h"
#define N 6
#define h0 0.1
#define pasmin 1E-6
#define pasmax 10
#define tol 1E-13
int rk78 (double *t, double x[], double *h,
          double hmin, double hmax, double tol,
          int n, int (*camp)(int n, double t, double x[], double f[], void *prm),
          void *prm);
int flux (double *t, double x[], double *h, double T,
          double pasmin, double pasmax, double tol, int npasmx,
          int n,
          int (*camp)(int n, double t, double x[], double f[], void *prm),
          void *prm);
int rtbps (int n, double t, double *x, double *f, void *prm);
/*
  Per compilar:
  gcc -o rtbps_int -g -Wall rtbps_int.c rtbps.c flux.c rk78.c  -lm
  Executar:
  ./rtbps_int 1.215058560962404e-2 < halos_inp.txt > halos.txt
*/
int main (int argc, char *argv[]) {
    double t,x[N],h,mu,T;
    int i, nt;
    if (argc!=2
        || sscanf(argv[1],"%lf",&mu)!=1
        ) {
        fprintf(stderr, "./rtbps_int mu\n");
        return -1;
    }
    /*
      posició, velocitat, temps, iteracions
    */
    printf("Ok");
    while(scanf("%lf %lf %lf %lf %lf %lf %lf %d", 
                &x[0],&x[1], &x[2], &x[3],&x[4],&x[5],&T,&nt)==8){
        printf("%lf %lf %lf %lf %lf %lf %lf\n", t, 
               x[0],x[1],x[2],x[3],x[4],x[5]);
        h=h0;
        t=0;
        for(i=1;i<=nt;i++){
            //t=0;
            flux(&t,x,&h,T/nt,pasmin,pasmax,tol,nt,N,rtbps,&mu);
            printf("%lf %lf %lf %lf %lf %lf %lf\n", t, 
                   x[0],x[1],x[2],x[3],x[4],x[5]);
        }
    }
    return 0;
}
On the top I copied the prototype of the functions I use, but they work so they're not the problem.
Thank you!
 
     
    