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 is the purpose of sprintf() function?

587


Explain pointer. What are function pointers in C?

616


How can I discover how many arguments a function was actually called with?

622


Explain what is wrong in this statement?

620


Explain what is wrong with this statement? Myname = ?robin?;

984






write a progrmm in c language take user interface generate table using for loop?

1561


Write a program for Overriding.

668


How many types of sorting are there in c?

594


How do I round numbers?

587


Why is #define used?

783


What is pre-emptive data structure and explain it with example?

3197


Why should I use standard library functions instead of writing my own?

660


What is a far pointer in c?

584


The number of measuring units from an arbitarary starting point in a record,area,or control block to some other point a) recording pointer b) offset c) branching d) none

696


In c programming, explain how do you insert quote characters (? And ?) Into the output screen?

750