# Pointer equivalent to array notation

• 12-05-2006
bekkilyn
Pointer equivalent to array notation
Hi all,

I bought the 2-volume C for Dummies books a long time ago and now a few years later, I have decided I am going to thoroughly learn pointers once and for all! Anyway, I've been going through the pointer chapter and haven't been having too much trouble so far, but then one of the exercises at the end of the section has me a bit stumped.

The exercise asks to match the array notation to its pointer notation equivalent.

So:

array[0] is equivalent to *a
array[1] is equivalent to *(a+1)
array[x] is equivalent to *(a+x)

No problems with these, but then:

array[i+2] is equivalent to *(i+2)

Where did this come from? Why wouldn't it be something like:

array[i+2] is equivalent to *(a+(i+2))

Or is this some sort of typo in the book?

Thanks!
• 12-05-2006
Dave_Sinkula
Looks like a typo, but direct quotes could help my 1% doubt.
• 12-06-2006
dwks
Those Dummies books are full of errors; I wouldn't be surprised if you've found one . . .
• 12-06-2006
bekkilyn
Thanks so much!

I'm at the point now where I'm pretty sure it's an error. Here's the exercise from the book exactly:

1. Match the array notation to its pointer notation equivalent:

A. array[0]
B. array[1]
C. array[i+2]
D. array [x]

1. *a
2. *(a+1)
3. *(i+2)
4. *(a+x)

1. A-1, B-2, C-3, D-4

Yep, it was just that simple to match up. None of them were switched around at all. I just couldn't figure out the whole i+2 thing. I wonder if it was supposed to be:

C. array[2]

```array[0]    == *array          array[1]    == *(array + 1)    array[i + 2] == *(array + i + 2) array[x]    == *(array + x)```