I have been asked for an assignment to use FisherYates shuffle on an array to be taken in from a file (that, I managed to do) using functions.
int FisherYates(int *player, int n) { //implementation of Fisher
int i, j, tmp; // create local variables to hold values for shuffle
for (i = n - 1; i > 0; i--) { // for loop to shuffle
j = rand(); //randomise j for shuffle with Fisher Yates
tmp = player[j];
player[j] = player[i];
player[i] = tmp;
}
return player;
}
It basically just needs to shuffle the list of players and return me the output so I can print it out in main().
I would very much appreciate it if anyone could show me how to modify the code to make it work, since with this version, I get a error at compile time:
invalid conversion from 'int*' to 'int' [-fpermissive]