I can not figure out why the values of voterFavorites are not changing here. Are arrays in c not referenced when returning from a function? I am planning on using voterFavorites in another method when determineWinner returns.
int determineWinner( int tallyCard[], int maxVotes, int numberOfRestaurants,int **voterFavorites) {
int x, y, z, zz, max = -999, min = 999, maxIndex, percent;
for ( x = 0 ; x < numberOfRestaurants ; x++ ) {
if (tallyCard[x] > max) {
maxIndex = x;
max = tallyCard[x];
printf("%i maxIndex; %i max\n", maxIndex, max);
}
if (tallyCard[x] < min) {
if (tallyCard[x] != 999) {
min = tallyCard[x];
}
}
}
percent = max * 100 /maxVotes;
printf("%i percent \n", percent);
if ( percent >= 50) {
return maxIndex;
} else {
for(x = 0; x < maxVotes ; x++) {
for (y = 0; y < 4; y++) {
if (voterFavorites[x][y] == min) {
voterFavorites[x][y] = 999;
}
}
}
return -444; // arbitrarily small number
}