arraySize


Login or Register for Dates, Times and to Reply

 
Thread Tools Search this Thread
# 1  
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  
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 for Dates, Times and to Reply

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

Test Your Knowledge in Computers #900
Difficulty: Medium
KornShell (ksh) is a Unix shell which was developed by David Korn at UC Berkeley.
True or False?

Featured Tech Videos