This question already has an answer here:
So this a function I wrote. It basically just transfers some data from one array to another when a condition is met. My issue is the while loop won't activate. I already confirmed "sizeof(arr1)/sizeof(arr1[0])" evaluates to 8 in my case, so my loop should run. It works if I actually put in an 8 instead of the code. I also tried static casting it to an int but that didn't work. Any insight would be appreciated!
void addWinners(person arr1[], person arr2[]) {
int k{0}, j{0};
while (k < static_cast<int>((sizeof(arr1)/sizeof(arr1[0])))) {
if (arr1[k].wins()) {
arr2[j] = arr1[k];
j++;
}
k++;
}
}
Aucun commentaire:
Enregistrer un commentaire