&a denotes the address of array
&a+1 increments &a by size of array and stores in ptr.....i.e. ptr points to
end of array
hence ptr-1 will print 5
--


Amol Sharma
Third Year Student
Computer Science and Engineering
MNNIT Allahabad




On Sat, Jul 23, 2011 at 6:03 PM, Akshata Sharma
<[email protected]>wrote:

> main()
> {
>  int  a[5] = {1,2,3,4,5};
>  int *ptr =  (int*)(&a+1);
>
>  printf("%d %d" , *(a+1), *(ptr-1) );
> }
>
> output: 2 5
>
> can someone please exlplain how we are getting 5?
>
> --
> 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.
>
>

-- 
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