A static variable is a variable that has been allocated statically — whose lifetime extends across the entire run of the program. This is in contrast to the more ephemeral automatic variables (local variables), whose storage is allocated and deallocated on the call stack; and in contrast to objects whose storage is dynamically allocated.
Static memory allocation refers to the process of allocating memory at compile-time before the associated program is executed, unlike dynamic memory allocation or automatic memory allocation where memory is allocated as required at run-time.
An automatic variable is a lexically-scoped variable which is allocated and de-allocated automatically when program flow enters and leaves the variable's scope.
Dynamic memory allocation (also known as heap-based memory allocation) is the allocation of memory storage for use in a computer program during theruntime of that program. It can be seen also as a way of distributing ownership of limited memory resources among many pieces of data and code.
In the C programming language, the function of static variables can be illustrated as such:
No comments:
Post a Comment