Difference between static variable and application variable

Static Variables

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.

Application Variables
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

2 thoughts on “Difference between static variable and application variable

  1. I just want to say I am all new to blogs and honestly liked you’re website. More than likely I’m likely to bookmark your blog post . You certainly have terrific writings. Thanks for revealing your web-site.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s