I was just messing around playing with some code then i suddenly see that after passing a array by reference sizeof(arr)/sizeof(arr[0]) is giving me other output than i expected.If i am just passing the reference then the len=1 may be justified since sizeof(arr[0])/sizeof(arr[0]).What is wrong with this any concept i am missing?
#include<iostream>
using namespace std;
void display(int *arr)
{
int len=sizeof(arr)/sizeof(arr[0]);
cout<<len<<"\n";
for(int i=0;i<50;++i)
{
cout<<arr[i];
}
cout<<"\n";
}
int main()
{
int arr[50]={0};
for(int i=0;i<50;++i)
{
arr[i]=i;
}
display(arr);
return 0;
}
Why is output of lenth not 50 as it should be?Why is it only 2 instead of 50.