I wrote an array_length function like this:
int array_length(int a[]){
return sizeof(a)/sizeof(int);
}
However it is returning 2 when I did
unsigned int len = array_length(arr);
printf ("%i" , len);
where I have
int arr[] = {3,4,5,6,1,7,2};
int * parr = arr;
But when I just do
int k = sizeof(arr)/sizeof(int);
printf("%i", k);
in the main function, it returns 7.
What is the correct way to write the array_length function and how do I use it?