+ 1

Please explain how last line of this code is giving output ?

https://code.sololearn.com/cpJTn29v3czO/?ref=app

22nd Mar 2022, 2:52 PM
Abhay mishra
Abhay mishra - avatar
2 Respostas
+ 1
10+2=12 int a[] = {0,1,-1,10,11} ; int *p = a ; initially p points to first location of array a by int p = a; that is *p = 0 next p = p+3 cause pointer to forward 4th (index 3) element and *p = 10. so *p+2 returns => 10+2 = 12
22nd Mar 2022, 2:59 PM
Jayakrishna 🇮🇳
0
G'day Abhay mishra nice code. Would you like a few pointer challenges? What about using a pointer to access a 2d char array, maybe days of the week? I still do that the long way: {my psuedocode} Create array Make a loop Use loop counter to multiply the pointer return, eg *(p+ i*arr2dSize)
22nd Mar 2022, 8:36 PM
HungryTradie
HungryTradie - avatar