7
This is the code I’m using, but the return of the tamVet function is not the vector size, but the pointer size on itself.
#include <stdio.h>
int tamVet(int *vet){
int tam;
tam = sizeof(vet) / sizeof(vet[0]);
return tam; //Está retornando 1 invés de 10, o número de elementos de vetor[10]
}
int main(){
int vetor[10];
printf("%i", tamVetor(vetor));
return 0;
}
"How to return vector size" I find an interesting question. But in your case, pq makes sure it’s with
sizeof()
?– Bacco
I don’t know any other way to get vector size
– robsonvca