Try searching a bit on the group before posting. This has been already discussed a couple of times on this group itself.
a is an array of 2 integers, thus sizeof(a) = 2*size of(int) = 8 &a is the address where the the address of the array is stored. Thus sizeof(&a) = sizeof(*pointer*) = 4 bytes(on your system). a+1 is address of a + sizeof(int) as a is an array of integers and it is in accordance to pointer arithmetic. similarly, since &a is referring to the whole array, when you add 1 to it, it is actually, &a+sizeof(a) .i.e address of a + 8. I hope I have explained your doubt properly. On 9 August 2011 03:54, Brijesh Upadhyay <[email protected]>wrote: > #include<iostream.h> > #include<conio.h> > > int main() > { > int a[2]={1,2}; > > cout<<sizeof(a)<<" "<<sizeof(&a)<<endl; > cout<<a<<" "<<&a<<endl; > cout<<a+1<<" "<<&a+1<<endl; > getch(); > } > > > It gives size of 'a' as 8 and '&a' as 4...which i hadnt expected.. and then > a+1 is increasing just 4 while &a+1 is increasing 8 in respectively 'a' , > '&a' ! why so?? > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To view this discussion on the web visit > https://groups.google.com/d/msg/algogeeks/-/2pJRgmCClNcJ. > 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. > -- ___________________________________________________________________________________________________________ Please do not print this e-mail until urgent requirement. Go Green!! Save Papers <=> Save Trees -- 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.
