I'm just starting out with pointers in C, and it's taking a bit longer than expected. I would like to print a pointer that points to a memory area of integers.
In the main program I have the following
int main(int argc, char* argv[]){
int tamano = 10, i = 0;
int *x = (int*) calloc(tamano, sizeof(int));
for(i = 0; i < tamano; i++){
x[i] = i+1;
}
imprimirPuntero(x);
return 0;
}
And in the procedure I have the following
void imprimirPuntero(int *ptr){
int i = 0;
printf("Valores: ");
for(i = 0; i < 10; i++){
printf("%d ", ptr[i]);
}
}
So my question really is... How do I know how many positions the pointer has, without passing that size to it in the procedure?