answersLogoWhite

0

Basically storage class defines the accessibity of a variable. If you specify a variable with auto storage class, then that variable can be accessed only in that function or block where it is declared. if you specify a variable with static storage class, it has the same visibily like an auto variable but it can retains it's value between function calls where as an auto variable cannot. look at this example: void main() { int i,j ;

for(j = 0; j< =2; j++) { i = fun1(); printf("%d",i); } } int fun1() { static int k =0; k = k+1; return k; } it prints 1 2 3

User Avatar

Wiki User

15y ago

What else can I help you with?

Related Questions

What are the storage classes in c?

A storage class defines the visibility and lifetime of variables or/and functions within a C Program. There are following storage classes which can be used in a C Program: auto register static extern


What is storage classes in c plus plus?

AUTO EXTERN STATIC are the storage classes in c++


How i useStatic extern int a in c?

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


What are Static variables in c?

A static variable in C is a variable whose value and memory allocation persists throughout the execution of the program. If the variable is declared at file scope (outside of any blocks) the static attribute means the variable is visible only to the file containing it, i.e. it can not be referenced through an extern reference in a different file.


What is the difference between extern and global?

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.


What is different storage class in c?

Different from what? Storage classes are auto, register, static, extern and typedef (formally).


Are C variables initialized to 0 by default?

Only global/static variables are, local variables aren't.


Auto static extern register?

Storage classes.


What is meant by the storage class of a variable?

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


Why you need to declare auto storage class specifier in c language?

We don't. The auto storage class is the default storage class for all local variables and is therefore completely redundant in C. It exists for no other reason than that C evolved from B and inherited all its storage classes (auto, static, extern and register).


Can static variables be declared in header file?

Can static variables be declared in a header file?You can't declare a static variable without defining it as well (this is because the storage class modifiersstatic and extern are mutually exclusive). A static variable can be defined in a header file, but this would cause each source file that included the header


What does extern C stand for?

"extern" is short of "external" which means outside.