Size Shrink of the array inside the function

#include
using namespace std;
void pass(int arr[])
{

cout<<"inside Fun: “<<sizeof(arr)<<” "<<sizeof(arr[0])<<endl;
}
int main()
{
int arr[]={5,8,4,6,28,4,5,6,9};
cout<<"Before Fun: “<<sizeof(arr)<<” "<<sizeof(arr[0])<<endl;
pass(arr);
}

output:-Before function:-36 4
After function:- 8 4

how this size is shrinking in function?

@gauravlodhi21 hey,before function calling size is correct but in function array is passed as pointer in parameter so in function sizeof will treat array as pointer and give size of pointer which is normally 8 therefore size is 8 ,also arr[0] is integer so give 4 as size.Hope you get it.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.