a[]={1,2,3,4} if passed in a function the value of a and if i compute sizeof(a) then it prints 8 and not 4. why? integer takes only 4 bytes. In main the sizeof(a) prints 16 only i.e. 4*4.
Passing array in function and calculating sizeof
When you pass the array to a function, it is passed by reference and it will be treated as a pointer. Now the size of that pointer will depend on your system architecture. It will be 8 bytes for 64bit systems and 4 for 32bit systems. Yours is a 64bit system so it is printing 8.
In the main where you are not passing the array, it will be treated as a normal integer array whose size will be 4xarray size=16bytes.