Exploring the static storage class
Sometimes, it is desirable to allocate memory in such a way that it can hold a value beyond the lifetime of automatic memory variables. An example of this might be a routine that could be called from anywhere within a program that returns a continuously increasing value each time it is called, such as a page number or a unique record identifier. Furthermore, we might want to give such a function a starting value and increment the sequence of numbers from that point. We will see how to do each of these.
Neither of these can be achieved easily with automatic storage classes. For this, there is the static
storage class. As with the automatic storage class, it can exist as both internal and external storage.
Internal static storage
When a variable is declared within a function block with the static
keyword, that variable is accessible only from within that function block when the function...