-3
When sorting a vector, in a function of type {void} why the vector (original) in my function call is shown as ordered since the vector that was ordered was the vector referring to the formal parameters of my function Sort(int Vector[], int TAM), because the ordered vector should be outside the memory scope of my vector main, since both arrangements are local variables, and the vector should be displayed Values[] is not ordered.
**void OrdenacaoBolha(int Vetor[], int TAM) {
int aux;
for(int i=0; i<TAM; i++) {
for(int j=0; j<TAM-1; j++) {
if (Vetor[j]>Vetor[j+1]) {
aux = Vetor[j];
Vetor[j] = Vetor[j+1];
Vetor[j+1] = aux;
}
}
}
}
int main(void) {
int Valores[] = {14, 32, 1, 7, 3, 2, 0};
int TAM = sizeof(Valores)/sizeof(int);
OrdenacaoBolha(Valores, TAM);
for(int i=0; i<7; i++) {
printf("%d\n", Valores[i]);
}
return 0;
}**
Ricardo, then in my second function I work nothing more, nothing less than just the references of each position of my original vector being a pointer. It must be why it is called passage by reference right?
– Nicolas Matheus Ferreira
Yes exact, you pass the reference, the object is one in memory :)
– Ricardo Pontual