I'm creating a program that sorts some numbers of a vector, and then is a bubble sort. I'm using a function called trocar
to change place numbers when one is larger than the other, but the compiler indicates that I can not use this function.
My code:
void trocar(int vetor[], int i) {
int temp = vetor[0];
vetor[0] = vetor[1];
vetor[1] = temp;
}
int main() {
setlocale(LC_ALL,"portuguese");
int vetor[5],i,trocar,trocado = false;
for(int i = 0; i < 5; i++) {
if(vetor[i] > vetor[i+1]) {
trocar(vetor[i],vetor[i+1]);
trocado = true;
}
}
}
It indicates the following error:
'swapping' can not be used as a function
How can I fix this error?