answersLogoWhite
C Programming
C++ Programming
The Difference Between

What is the difference between static and extern?

212223

Top Answer
User Avatar
Wiki User
2006-08-08 06:21:53
2006-08-08 06:21:53

Storage classes are used to indicate duration and scope of a variable or identifier. Duration indicates the life span of a variable. Scope indicates the visibility of the variable. The static storage class is used to declare an identifier that is a local variable either to a function or a file and that exists and retains its value after control passes from where it was declared. This storage class has a duration that is permanent. A variable declared of this class retains its value from one call of the function to the next. The scope is local. A variable is known only by the function it is declared within or if declared globally in a file, it is known or seen only by the functions within that file. This storage class guarantees that declaration of the variable also initializes the variable to zero or all bits off. The extern storage class is used to declare a global variable that will be known to the functions in a file and capable of being known to all functions in a program. This storage class has a duration that is permanent. Any variable of this class retains its value until changed by another assignment. The scope is global. A variable can be known or seen by all functions within a program.

1

Related Questions

User Avatar

extern variables are defined in different than the file where the main() is. extern variables can be accessed from other files. Static global variables are visible only within the file.

User Avatar

Variable-declaration is: extern int x; extern double y; extern char a; Variable-definition is: int x; static double y; auto char a; Variable-definition with initialization is: int x = 1; static double y= 2.3; auto char a = 'w';

User Avatar

There are four storage classes in ca) autob) registerc) staticd) extern

User Avatar

no they cant ... static says ... hey my var is within file scope. extern says .. var is defined some where else .... static var definition cant be seen by other file via their translation tables.... SO extern with static is an erroneous combination sujay0987@yahoo.com

User Avatar

It are static, auto and extern.

User Avatar

There is no difference between public static void and static public void

User Avatar

difference between static ip and public ip

User Avatar

difference between constant and static variables in java

User Avatar

No such thing, pick one ot the three: static int x; extern int x; int x;

User Avatar

What is the difference between complex permittivity and static dielectric conatant?

User Avatar

In c static and global variables are stored in data segment ( which is a special memory in RAM)

User Avatar

difference between static data member and static member function

User Avatar

The difference between static elecrtricty and lightning is nothing! Lightning is a bigger more powerful form of static electricity. - Drewza

User Avatar

static, extern, auto, register (and typedef, but only formally)

User Avatar

auto, extern, static, register, typedef (only formally)

User Avatar

in my own explanation static charge is a reaction between the (+)protons and (-)electrons an the effect of this reaction is called static electricity.

User Avatar

Extern and Global are the storage space in C program. Global provides us to access the variables from anywhere inside the program only whereas Extern provides us to access the variables from outside that program, i,e., some other program.

User Avatar

AUTO EXTERN STATIC are the storage classes in c++

User Avatar

For example 'int' is a data-type, 'short', 'long', 'signed' and 'unsigned' are modifiers, 'extern', 'auto', 'static', 'register' are storage-classes. The declarations go like this: storage-class modifiers data-type identifier example: static unsigned short int x;

User Avatar

one of these: static, extern, auto, register, typedef (just formally!)

User Avatar

Dynamic means in motion, static means motionless.

User Avatar

Static stays the same and dynamic is always different.

User Avatar

static line jumps are static, free fall are not :P

User Avatar

global means: defined here, available from everywhereexternal means: defined elsewhere


Copyright © 2020 Multiply Media, LLC. All Rights Reserved. The material on this site can not be reproduced, distributed, transmitted, cached or otherwise used, except with prior written permission of Multiply.