+ 1

Please explain how this pointer still hold the value of variable a?

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

29th Jun 2020, 6:07 AM
SAURAV KUMAR
SAURAV KUMAR - avatar
6 ответов
+ 3
SAURAV KUMAR Because ptr is a global variable.
29th Jun 2020, 6:22 AM
A͢J
A͢J - avatar
+ 1
SAURAV KUMAR Yes the value of a will destroy but as you know ptr is global variable and it will hold the value of a before destroy the value of a. You are not destroying the value of ptr anywhere so it will always have the value of a
29th Jun 2020, 6:28 AM
A͢J
A͢J - avatar
+ 1
Ohhh... Thank you
29th Jun 2020, 6:29 AM
SAURAV KUMAR
SAURAV KUMAR - avatar
+ 1
Now I completely understand... Thanks Martin Taylor
29th Jun 2020, 1:53 PM
SAURAV KUMAR
SAURAV KUMAR - avatar
0
But variable a is local to the func . So after finishing the func value of a is destroyed na...
29th Jun 2020, 6:24 AM
SAURAV KUMAR
SAURAV KUMAR - avatar