What are Storage Classes in C ?

Answer Posted / vijayalakshmi

There are four types of storage classes in c. It defines the
scope and lifetime of a variable or function.

1. auto - This is the default storage class. Auto can only
be used with in functions. i.e. only for local variables,
not for globals.

2. register - The variables declared using the register
storage class may stored in cpu registers instead of RAM.
Since it doesn't have a memory location, the '&' operator
for getting the address of the variable cannot be applied
(in C). This storage class cannot be used for global scope data.

3. static - This is the default storage class for global
variables. In case of local variable, it is initialized at
compile time and retains its value between the calls. By
default the static variables will be initialized to zero,
incase of pointer variable initialized to NULL.

4. extern - Defines the global variables that is visible to
all object modules. This type of variables cannot be
initialized, since it is pointing to a storage location,
where it is previously define.

Is This Answer Correct ?    12 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the benefits of c language?

637


What do you understand by friend-functions? How are they used?

633


Explain what is the difference between null and nul?

644


Why c is a mother language?

545


What is the purpose of & in scanf?

586






What is the main difference between calloc () and malloc ()?

562


What language is windows 1.0 written?

563


write a program to create a sparse matrix using dynamic memory allocation.

4363


How does pointer work in c?

608


Explain how do you sort filenames in a directory?

594


hai iam working in sap sd module for one year and working in lumax ind ltd in desp department but my problem is i have done m.b.a in hr/marketing and working sap sd there is any combination it. can you give right solution of my problem. and what can i do?

1652


Explain is it valid to address one element beyond the end of an array?

722


Define C in your own Language.

628


Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;

601


What is the difference between abs() and fabs() functions?

597