Lets say i want to write a function that returns me the size of an array. some thing like
“”"
int calcNumberOfElements (int arr[]) {
int numberOfElements = sizeof(arr)/sizeof(int);
return numberOfElements;
}
“”"
since arrays are passed as a refernece , sizeof(arr) returns the size of int * rather than the array. So how can i modify this function to return me the number of elements in an array ?