jeudi 26 mars 2020

Getting c core dumped error and trying to get random integers [duplicate]

I am trying to get random numbers between 0 and 11 but I am getting segmentation fault core dumped error here is my code:

void track_machine(){
        int *X = 0,*Y = 0; //Coordinates
        double *D = 0,*R = 0; //Distance and replacement
        refresh_position(X,Y,D,R);
        printf("%d",*X);
        printf("%d",*Y);
}
void refresh_position(int *X, int *Y, double *D, double *R){
        *X = rand();
        *Y = rand();
}

I am running the track_machine() from my main function then i get an error.




Aucun commentaire:

Enregistrer un commentaire