The Gateway to Computer Science Excellence
+1 vote
155 views
int arr[]={1,2,3,4,5};

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

what is the meaning of p2 ????? please explain
in Programming by (307 points) | 155 views
0
P2 is a pointer pointing to array value 2 (integer)
0
i am not understand please explain in detail ,

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

what is the output,according to above question.
+3

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

0
Yes..👍
I was wrong. :(

1 Answer

–1 vote
P2 is an integer pointer and the address of 2nd slot of the array is assigned to p2.
by (459 points)
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
50,737 questions
57,297 answers
198,265 comments
104,977 users