arraySize


 
Thread Tools Search this Thread
Top Forums Programming arraySize
# 1  
Old 09-19-2007
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);
}
# 2  
Old 09-19-2007
Answer is - you can't. Smilie As all you get in fun is a pointer.

however, you can with a macro

#define fun(x) (sizeof(x)/sizeof(x[0]))
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question