*p[] is an array of pointers pointing to the address of array a[] .. i.e
p[0] pointing to a[0]..p[1] to a[1] and so on.

*pp is a pointer to a pointer. It is storing the address of array of
pointers p.
1. *pp gives value at pointed by p[0]. This is 'a'. So when 'a' is
subtracted from it, it returns 0.
2. pp gives the address of pointer p. This is same as 'p' as it also
denotes address of pointer p. Therefore 0 again.
3. **pp gives value at pointer p[0]. That is it gives value a[0] which is 0.
 pp++, ++p, *++p ..all these increment address of pp pointing to and not
the value.
   So, it increments pp to +4 address of what it was previously pointing to.
4. pp-p means subtracting address of old pp and new pp, which must be four
as address p+4 = address new pp.
5. (*pp -a) means subtract value where pp is pointing -'a' . As pp is
incremented 4 times, it is pointing to 'a+4' . So ans is a+4-a which is 4.
6. Lastly, **pp gives the value of address stored at (*p) i.e. *(a+4) which
is a[4]. Value of a[4] = 4 and so in the answer ;)


On 16 June 2012 22:25, Shubham Sandeep <s.shubhamsand...@gmail.com> wrote:

> #include<stdio.h>
> main()
> {
>     int a[] = {0,1,2,3,4};
>     int *p[] = {a,a+1,a+2,a+3,a+4};
>     int **pp= &p;
>     printf("%d, %d, %d ", *pp-a, pp-p, **pp);
>     pp++;
>     pp++;;
>     ++pp;
>     *++pp;
>     printf("%d, %d, %d ", pp-p, *pp-a, **pp);
>  }
>
> output:0 ,0 ,0 ,4 ,4 ,4
>
>
> --
> 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.
>



-- 
Sajal Choudhary
Undergraduate Student,
Division of Computer Engineering,
Netaji Subhas Institute of Technology,
New Delhi.

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