arraySize

Hi ,

I like to find the size of an array in the function which takes an array as a parameter .

eg:

void fun(int a[])
{
// Size of an array `a` to be calculated here
}

int main()
{
int a[10];
fun(a);
}

Answer is - you can't. :slight_smile: As all you get in fun is a pointer.

however, you can with a macro

#define fun(x) (sizeof(x)/sizeof(x[0]))