ok, you said that global variables are neither store in stack nor heap......but as we know that memory allocated in stack remains in existence for the duration of a program, and it is sufficient for global variable.....th en why we not use stack for storing of global variables
storage of global variable
Collapse
X
-
All the language spec says regards the duration of the storage.
Variables defined inside a function need to live for the duration of the function. Often this storage is referred to as stack storage.
Variables defined outside a function must exist for the duration of the program. Often this storage is called static storage. How this is implemented by a particular compiler is irrelevant.
There is no such thing as a global variable. This is the popular name for variables in static storage with external linkage.
Read this: http://bytes.com/topic/c/insights/73...obal-variables
Comment