Both the commented functions return the exact same memory address. So why can I get the correct size from an array variable (pointer to first element) and I cannot get the size from an array pointer (array parameter) when there seems to be absolutely no difference (exact same memory address):
#include <stdio.h>
void arraySize(int arr[]) {
printf("%p\n", arr); // same memory address
printf("%lu\n", sizeof(arr) / sizeof(arr[0])); // different result
}
int main() {
int a[] = {1,2,3,4,5};
printf("%p\n", a); // same memory address
printf("%lu\n", sizeof(a) / sizeof(a[0])); // different result
arraySize(a);
return 0;
}