|
-
May 13th, 2003, 05:40 AM
#1
Thread Starter
Fanatic Member
#elements in array in functions
Firstly, i know that in normal "int main(void)" stuff, to find the # of elements in an array, say int p[], you do:
num_elem=sizeof(p)/sizeof(int)
(**i think sizeof(p)/sizeof(p[0]) is more general**)
However, i was passing an array to a function:
int my_func(int q[])
{
cout<<sizeof(q)<<endl; //Gives 4 (=sizeof(int)) every time
}
I was just wondering if there was a nice way to find the size of an array passed to a function??
Thanks
sql_lall 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|