1
I’m creating a program that sorts some numbers from a vector, so it’s a bubble sort. I’m using a function called trocar
to exchange seat numbers when one is larger than the other, but the compiler indicates that I cannot 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 :
'change' cannot be used as a function
How can I correct this mistake ?
Thanks again merchant for helping me, this was a mistake I ended up letting go unnoticed.
– Monteiro