I would like to find the size of the integer array passed as an argument to the function. Here is my code
void getArraySize(int arr[]){
int len = (sizeof(arr)/sizeof(arr[0])
printf("Array Length:%d\n",len);
}
int main(){
int array[] = {1,2,3,4,5};
getArraySize(array);
return 0;
}
I get the following warning
sizeof on array function parameter will return
size of 'int *' instead of 'int []' [-Wsizeof-array-argument]
Please help so that I can find the length of the integer array inside function getArraySize
However, I can find the size arrayinside the function main. Since it is referred to as pointer, I cannot find lengthfrom c function.
I have an idea, although I could add this to a block try/catch( Cdoesn't have a try catch, Only jumpers , which is OS dependent) and loop until I get it segmentation fault.
Is there any other way that I could use to find the length integer arrayinsidefunction