+ 2

What happened at last cout.

I couldn't get the logic why it increment https://code.sololearn.com/cMgSy0xbwORg/?ref=app

11th Mar 2018, 7:50 PM
Shubham
Shubham - avatar
2 Réponses
+ 3
i[3] is a local array which means that its memory on the stack will be made available for other variables after its scope (the function) ends. *a is pointing to the memory of i[3] in f(1). g(2) overwrites the memory *a is pointing to. Therefore *a is g(2). I hope this is correct, but it makes sense to me.
11th Mar 2018, 8:19 PM
Chris
Chris - avatar
0
this seems logical for my program. thanks can you see what's in difference there.i just modified this program to check your logic. https://www.sololearn.com/discuss/1136603/?ref=app
11th Mar 2018, 9:54 PM
Shubham
Shubham - avatar