Re: pointer arithmetic
- From: "Neil Ferguson" <neilNOSPAMdNOSPANferguson@xxxxxxxxxxx>
- Date: Fri, 23 Jun 2006 10:19:22 -0700
<barikat@xxxxxxxxx> wrote in message
news:1151077831.567780.241310@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
int a[5];If you live at 301 Elm Street and your friend lives at 303 Elm Street and
int *Ptr1, *Ptr2;
Ptr1 = a;
Ptr1++;
Ptr2 = a;
printf("Ptr1 : %p\n", Ptr1);
printf("Ptr2 : %p\n\n", Ptr2);
Ptr1 = Ptr1 - Ptr2;
---------------------
Ptr1 : 0012FF6C
Ptr2 : 0012FF68
Ptr1 : 00000001
Ptr2 : 0012FF68
----------------------
i couldnt understand, Ptr1 = Ptr1 - Ptr2; line is a pointer arithmetic,
and Ptr1 should be 0012FF6C, because Ptr1 is a[1] and Ptr2 is a[0]
a[1] - a[0] should be a[1] so 0012FF6C
probably i am wrong but i wanted to ask :)
houses on your side of the street are odd-numbered, how many houses away
from you does your friend live?
N
.
- References:
- pointer arithmetic
- From: barikat
- pointer arithmetic
- Prev by Date: Re: Why pointer to "one past" is allowed but pointer to "one before" is not ?
- Next by Date: Re: Why pointer to "one past" is allowed but pointer to "one before" is not ?
- Previous by thread: Re: pointer arithmetic
- Next by thread: Re: pointer arithmetic
- Index(es):
Relevant Pages
|