I am wondering how C or C++ manages static variable internally. Since each time when we again a function again, if in this function, a static variable is defined, the value will be the value last time when we entered this function (i.e. will not be initialized again, and only initialized at the 1st time).
I suspect it is stored in some global structure to reserve the value?
thanks in advance,
Look at it basically as a global but with limited scope... only within the function where it is declared.
Actually, good question. Are they stored on the heap or the stack is perhaps your question? And here is your answer.