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};
func(a);
return 0;}
int func(int a[])
{ //how to know the size of the a if size is not passed to the function
You have to pass the size of an array to function as parameter, otherwise there is no way to know the number of elements in array. Unlike a string in c which is terminated by a ‘\0’ character, there is no such termination character for arrays in C.