in Programming
346 views
1 vote
1 vote
int arr[]={1,2,3,4,5};

int *p2=(int*)(&arr+1);

what is the meaning of p2 ????? please explain
in Programming
346 views

4 Comments

P2 is a pointer pointing to array value 2 (integer)
0
0
i am not understand please explain in detail ,

printf("%d",*(p2-1));

what is the output,according to above question.
0
0

It will print 5. (last element of the array)

&arr+1 =  &arr+ (5*size of int)

*(p2-1) = p2[-1]

See this: https://gateoverflow.in/232228/array-and-pointer

3
3
Yes..👍
I was wrong. :(
0
0

1 Answer

–1 vote
–1 vote
P2 is an integer pointer and the address of 2nd slot of the array is assigned to p2.