Static variable memory destruction
-
12-11-2019 - |
Question
A static variable is defined in a function.Can v destroy its memory outside that function?
Solution
If you're talking about C, then no you can't "destroy its memory" - all your static variables are going to be around for as long as your program is running.
OTHER TIPS
What do you mean by "destroy its memory"?
If you mean 'free' the memory, the answer is no.
If you mean overwrite it, the answer is yes (a pointer to the variable can be given to something outside the function that 'owns' it, or a common bug could trash the memory).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow