jeudi 26 mars 2020

Can't get random numbers in c

I am trying to get two random numbers between 0 and 11 but i get the same number whenever i execute my code. These numbers are 7 and 10. 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\n",X);
        printf("%d\n",Y);
}
void refresh_position(int *X, int *Y, double *D, double *R){
        *X = rand()%12;
        *Y = rand()%12;
}



Aucun commentaire:

Enregistrer un commentaire