Hey everyone, I'm trying to implement bubble sort in c++ with the requirement that it uses pointers instead of regular arrays. I have the algorithm entered, but on the line where the if statement checks the if the current element is greater than the next element, I get the error, "Indirection requires pointer operand ('double' invalid)" If anyone knows what's causing this, please let me know, below is the code.
void sort(double *scores, int numberOfScores) {
bool swapped;
for(int i = 0; i < numberOfScores - 1; i++) {
swapped = false;
for(int k = 0; k < numberOfScores - i - 1; k++) {
if(*(scores[k]) > *(scores[k+1])) {
swap(&scores[k], &scores[k+1]);
swapped = true;
}
}
if (!swapped)
break;
}
}