Question: I am seeking for an explanation regarding how incrementing an address affects a pointer.

I learned about how C pointers work and how incrementing a pointer is done by considering the pointer type. still I don't understand the following case

```
int main()
{
    int a[] = {1,2,3,4,5};
    int *p = (int*)(&a+1);
    printf("%d\n%d\n", *(a+1), *(p-1));
    return 0;
}

```

I expected this line

```
int *p = (int*)(&a+1);

```

to make `p` point to the address that follows array `a`, therefore I expected the output:

```
2 

```

**as it is simply `a[1]`**

But the output was *unknown\_number* - **as I don't know which int is 4 bytes behind `(&a+1)`**

And the actual result is:

```
2

5

```

Why does it seems that `p` points directly to the memory sitting after `a`?

What is the source for my confusion?

Answer: 
So in this example `&a` is of type `int(*)[5]`. When you add 1 to it it actually adds `sizeof(int[5])` - because that is how pointer arithmetic works, adding an offset adds the size of the type being pointed to times the offset. That is how you get `p` to be one past last element of `a`, after which you cast it to `int*` so now you have a pointer pointing to an integer at an address one past the last element of `a`. So effectively, subtracting 1 from it gives you the last element of `a`.
You can manipulate the array `a` as a pointer to a int `int *`. But it is not the same for `&a`, which is a pointer to an array of 5 ints : `&a + 1` will add the size of the 5 ints to the pointer.

Just remove the `&` before adding 1 to a, and it'll work as you expected:

```
#include <stdio.h>

int main()
{
    int a[] = {1,2,3,4,5};
    int *p = (int*)(a+1); // & removed
    printf("%d %d\n", *(a+1), *(p-1));
    return 0;
}

```