Find the Size of integer array received as an argument to a function in c [duplicate]

You cannot do it that way. When you pass an array to a function, it decays into a pointer to the first element, at which point knowledge of its size is lost.

If you want to know the size of an array passed to the function, you need to work it out before decay and pass that information with the array, something like:

void function (size_t sz, int *arr) { ... }
:
{
    int x[20];
    function (sizeof(x)/sizeof(*x), x);
}

The array decays to a pointer when passed.

So sizeof only works to find the length of the array if you apply it to the original array.

So you need to pass length of array as separate argument to function.