c - When is a local static variable stored in memory? -


At what point does the compiler need to store the local static variable in memory? Is this time in compiling? Or at runtime, when the function contains the local static variable?

  int * GetMyVariable () {static int A = 50; Return and A; }  

I want to use memory only for 'A' if GetMyVariable () is called if the static does not work this way, then what is a dynamic allocation mine Is the only option? Thanks for your time.

When a local static variable is stored in memory

< P> This is done before the execution of the program.

(C99, 6.2.4p3) "An object whose identifier has been declared with an external or internal relationship, or the storage class specification is the static storage period of the static. Its lifetime is fully executed with the program And its stored value is only started once, before program startup. "


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -