Size of Array

I encountered a problem while coding for a program. When we pass an array through reference to a function then how can we know about the size of the array that is passed . Remember that we are not passing the size of array.

int main()

int a[]={1,2,3,4,5,5,3,2};


return 0;}

int func(int a[])

{ //how to know the size of the a if size is not passed to the function

return 0;

AFAIK that’s not possible in C++, you have to pass size too or you have to use terminating element similar to C strings.

1 Like