Array length

How to determine array length when array of int-s is passed as parameter to the function?

void someFunction(int arr[])
{
int lengthOfArray = ... ?
}

Solution from site:

sizeof(myInts)/sizeof(int)

does not work. It returns 1 always when variable is passed as parameter.

It isn't possible to simply do what you want in C.
There's usually a workaround, depending on how you use the array, like using the macro you found as an argument to the function.

void someFunction(int arr[], int length)
{
}

someFunction (myArray, sizeof (myArray) / sizeof (myArray[0]));

Yeah, thanks!

It makes sense to me now. In my case, it was the length of pointer to array I think and it's always one. Correct me if I'm wrong

It's two.

My bad again!

I've used it in a random(min, max) function as max, and it returns random number between min and max-1.

Oh I really need to learn C again..