+ 1

Assume you declared int *p and p's current value is 1000. What is p + 1? Please any help?

#pointers

15th May 2019, 4:16 PM
Roy Emmanuel
Roy Emmanuel - avatar
9 ответов
+ 4
p is a pointer holding address of a int variable. Value of p depends on size of int. Size of int depends on the compiler. In general 32 bit systems will have int size as 4 bytes (32 bit = 4*8 bit = 4bytes) to store int value. So, if p=1000, then p+1=1000+4(size of int) =1004. Hope this helps...!!!
15th May 2019, 4:48 PM
Kuri
Kuri - avatar
+ 3
~ swim ~ is the Sizeof always 4?
15th May 2019, 4:47 PM
Roy Emmanuel
Roy Emmanuel - avatar
+ 3
~ swim ~ thank you🙏🙏
15th May 2019, 5:01 PM
Roy Emmanuel
Roy Emmanuel - avatar
+ 1
yes thanks Nagendra so the 4 bit is always multiplying the number u plus it with the P ryt? i.e. P+3= 1000+3*4 right?
15th May 2019, 4:54 PM
Roy Emmanuel
Roy Emmanuel - avatar
+ 1
~ swim ~ so assuming it was p + 2, will it be like p= 1000 + 2*4.. which is 1008?
15th May 2019, 4:56 PM
Roy Emmanuel
Roy Emmanuel - avatar