Visit Our UNIX and Linux User Community


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]))

Previous Thread | Next Thread
Test Your Knowledge in Computers #904
Difficulty: Medium
The benchmark used in the LINPACK Benchmark is to solve a dense system of nonlinear equations.
True or False?

Featured Tech Videos