Quote:
Originally Posted by The Dark
Note that this code will only work from within main. If you made a function using this code, the "name" array will go out of scope while the environment is still using it.
|
The entry point of your program is the main function. In the main functions, you usually call a number of functions. Does this mean your main function gets out of scope? Well, no. When you call function x, your variables from the main function are still on the stack. How else could you return from function x and continue in your main function?
Your local variables in function main will get unavailable once you return from the main function. And what happens when you quit the main function? Your program is finished, and the variable is no longer used anyway.
I'm not sure how this applies when running multiple threads, it may be OS specific (running another thread while main thread has finished) - another member can probably tell you that. I usually block the main thread when it has ended and other threads have not.