Following is the program to calculate the array length:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
void fun(int a[])
{
int size = sizeof(a)/sizeof(int);
cout << "In function " << size << endl;
}
int main()
{
int a[]={0,1,2,3,4,5,6};
int size = sizeof(a)/sizeof(int);
cout << "In main " << size << endl;
fun(a);
return 0;
}
The output I get is:
In main 7
In function 1
Could someone please help me why is this difference?