c++ - Why value of local variable(its address is stored in global variable) is freed when function has completed its execution -


this code

#include<iostream> using namespace std; int *ptr; void hold(){   int a=12;   ptr=&a; };  int main(){   hold();   cout<<"value of a="<<*ptr; }; 

and value of a=12 must not happen because compiler has freed value @ address of why 12 comes?

freeing doesn't mean system modify value stored there (which involve unnecessary overhead). means memory space made available future storage.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -