Visit Our UNIX and Linux User Community


Thread Tools Search this Thread
Top Forums Programming arraySize
# 1  
Old 09-19-2007

Hi ,

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


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

int main()
int a[10];
# 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