*chunk

On Wed, Aug 3, 2011 at 11:40 AM, Arun Vishwanathan
<aaron.nar...@gmail.com>wrote:

> hmm i get it..thanks sandeep and thavasi...
> i guess i was confused cos arr holds address of first element of array so
> it forced me to think along lines of a pointer only...
>
> @sandeep: i guess yes when u mention as exceptions then only it is
> understandable cos as a general interpretation it is difficult to follow
> since arr holds address (of first element)
> so sizeof(arr) seems tempting to take as the size of address it holds....
>
> so for example if we have int (*p)[10] which is a pointer to 10 ints
> sizeof(p) returns 4 but int a[10] , if we have sizeof(a) it wud return
> 40(4*10) though both a and p hold the starting addresses of the chuck ..
>
>
>
> On Wed, Aug 3, 2011 at 11:28 AM, Sandeep Jain <sandeep6...@gmail.com>wrote:
>
>> When you refer to an array name, it is usually interpreted as the "address
>> of the first element of the array", (try not calling it pointer to the first
>> element its less confusing that ways)
>> However there are exceptions,
>> 1) When used as a parameter to sizeof, it returns the total number of
>> bytes allocated to that array
>> 2) When address-of operator is used with an array name, it returns the
>> "address of the entire array" i.e. &arr is address of the array(which is
>> numerically the same value as the address of the first element)
>>
>> And when you say sizeof(&arr), its similar to sizeof(--some address--) all
>> addresses/pointers have same size irrespective of type to which the pointer
>> points.
>>
>>
>>
>> Regards,
>> Sandeep Jain
>>
>>
>>
>>
>> On Wed, Aug 3, 2011 at 2:42 PM, Arun Vishwanathan <aaron.nar...@gmail.com
>> > wrote:
>>
>>> hi i have a slight confusion..i got the above explanation but i have a
>>> doubt as in when u say int arr[5], arr is also the pointer to the first
>>> element of the array right?..so size(arr) shudnt be the size of pointer
>>> (which is int 4 byte address it holds of the first array element?) ..is it
>>> not interpreted this way?....and sizeof(&arr) looks like address of the
>>> pointer itself which also will be int (4 bytes)??
>>>
>>>
>>> On Wed, Aug 3, 2011 at 5:59 AM, Thavasi Subramanian <
>>> sktthav...@gmail.com> wrote:
>>>
>>>> Ur compiler might have supported 4 bytes to store an integer value....
>>>>
>>>> sizeof(arr)
>>>> Since the array is capable of holding 5 integer values at the most total
>>>> byes required=4*5=20 byte.
>>>>
>>>> Now, sizeof(&arr)
>>>> Here you referred the starting address of the array and the addresses
>>>> are integer values the output is as same as sizeof(int)=4 byte
>>>>
>>>> So you get 20 4 as output
>>>>
>>>> Hope you got it.... :)
>>>>
>>>>
>>>> On 3 August 2011 01:45, Anuj kumar <anonymize...@gmail.com> wrote:
>>>>
>>>>> #include<stdio.h>
>>>>> #include<conio.h>
>>>>> int main()
>>>>> {
>>>>>  int arr[5];
>>>>>  printf("%d %d\n",sizeof(arr),sizeof(&arr));
>>>>>     getch();
>>>>>     return 0;
>>>>> }
>>>>>
>>>>> o/p  20    4
>>>>>
>>>>> anybody can tell me how 20 is coming plzz
>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "Algorithm Geeks" group.
>>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>>> To unsubscribe from this group, send email to
>>>>> algogeeks+unsubscr...@googlegroups.com.
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/algogeeks?hl=en.
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Thavasi
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Algorithm Geeks" group.
>>>> To post to this group, send email to algogeeks@googlegroups.com.
>>>> To unsubscribe from this group, send email to
>>>> algogeeks+unsubscr...@googlegroups.com.
>>>> 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 algogeeks@googlegroups.com.
>>> To unsubscribe from this group, send email to
>>> algogeeks+unsubscr...@googlegroups.com.
>>> 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 algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com.
>> 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 algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to