First off, always indent and space your code, even in a little scrap of program like this - it makes it a lot easier to read:
int main()
{
int a[5];
int *ptr;
ptr = a;
for(int i = 0;i < 5; i++)
{
scanf("%d", ptr);
printf("%p\n", &ptr + i);
ptr++;
}
}
The difference between
printf("%p\n", &ptr + i);
and
printf("%p\n", &ptr);
is obvious: in one you add a variable value
i
to static value
&ptr
and in the other you don't.
Think about it:
ptr
is a variable which contains the address of an array element in memory - but as a variable it is also stored somewhere, so it has it's own address
&ptr
which doesn't change when you alter the value the variable contains.
Try this:
int main()
{
int a[5];
int *ptr;
ptr = a;
printf("%p\n", ptr);
printf("%p\n", a);
printf("%p\n", &ptr);
printf("%p\n", &a);
}
And see what you get.