@tarak:

You can see it like this. When we create an array then 'a' points to the
whole array not just the first element so it returns the size of the whole
array.

when you pass the array though by default in c it is pass by value but as
you are passing the address of the array so it acts like pass by reference.
So the formal parameter acts as a pointer when you pass the address of the
array to it.

And you know that the size of a pointer is always equal to the size of int.



On Sun, Jul 25, 2010 at 12:31 AM, tarak mehta <[email protected]>wrote:

> void hell(int arr[]);
> main()
> {
>        int arr[]={1,2,3,4,5};
>
>
>        hell(arr);
> }
> void hell(int arr[])
> {
> printf("%d",sizeof(arr)/sizeof(*arr));
> }
> even this gives 1 !!
> @manjunath ur idea seems correct..but could u plz elaborate a bit
>
>
>
> On Sat, Jul 24, 2010 at 10:51 PM, Manjunath Manohar <
> [email protected]> wrote:
>
>>
>>
>> when arrays are passed as arguments to a function,the starting address of
>> the array is passed like a pointer,
>> thus sizeof(arr)=2..thus 2/2=1..this is the precise reason for always
>> specifying the column length in the definition of function when functions
>> have arrays as one of the arguments..
>>
>> Hope i made any sense.. :)
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected]<algogeeks%[email protected]>
>> .
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>



-- 
regards

Apoorve Mohan

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to