1. Global variable (example : int i_Global)
Defines a global variable, allocating memory for it which will be accessible by all files in the program.
2. Extern variable (example : extern int i_Global)
Declares a global variable which is defined in another file. No memory is allocated. This is how global variables defined in one file can be used in another.
3. static variable (example : static int i_Local means in .h file)
static local variables retain their values on repeated calls into the function unlike other local variables.
4. static global variable ( example : static int i_Global)
These global variables can only be accessed from within the file. Using the static keyword you can declare global variables with the same name in multiple files in the same program.
1. Variables defined local to a function disappear at the end of the function scope. So when we call the function again, storage for variables is created and values are reinitialized.
2. So if we want the value to be extent throughout the life of a program, we can define the local variable as "static." Initialization is performed only at the first call and data is retained between func calls.
3. Static variables are local in scope to their module in which they are defined, but life is throughout the program. Say for a static variable inside a function cannot be called from outside the function but is alive and exists in memory.
1. Global Variables are also similar to the static variables but these variables are available outside the module/function and its scope is available through out the application.
2. These Variables can be accessed from any of the function
Shanky11, if this helps please login to Mark As Answer. | Alert Moderator