void fun(int arr[8])
{
printf("\nArray size inside fun() is %d", sizeof(arr));
}
int main()
{
int arr[8] = {1, 2, 3, 4, 5, 6, 7, 8};
printf("Array size inside main() is %d", sizeof(arr));
fun(arr);
return 0;
}
Why the size of array arr[8]
inside function fun()
is 4 bytes and array arr[8]
in function main() is 32 bytes? Although they can store 8 integers each of 4 bytes. The size of the array arr[8]
in func() should have also been 32.
What actually happens when we pass an array as a parameter?