The local pointer will be remove after i go out from that scope? or will remain?


int glb1 = 2;

int main ()
    int var1 = 0;        

    //at here

void fnCall1 ()
    int tmp1;    
    tmp1 = 10000;

void fnCall2 ()
    int *ptr1;    
    ptr1 = &glb1;
    *ptr1 = 20;

If.. the address for variables:
glb1 0004
var1 0008
tmp1 0012
*ptr1 0012

then will the local pointer is permenant exists? so 0012 value will forever pointing glb1? so the tmp1 value might change?

if you are talking about ptr1 then it is destroyed when you exit fnCall2 and recreated the next time you enter the subroutine. You cannot rely on it retaining its value.

You pointed the pointer (sic) to an external variable, which won't go out of scope until the translation unit (source file) terminates. The variable itself will terminate when the function is finished, but the external variable glb1 will retain the value you set inside the call fnCall2().