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

Write a program to identify if a given binary tree is balanced or not.

691


When reallocating memory if any other pointers point into the same piece of memory do you have to readjust these other pointers or do they get readjusted automatically?

813


What is pointers in c with example?

589


What is the right type to use for boolean values in c? Is there a standard type? Should I use #defines or enums for the true and false values?

610


Which is the best website to learn c programming?

587






How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?

592


What are void pointers in c?

579


What's a good way to check for "close enough" floating-point equality?

634


What is keyword with example?

646


How can I access an I o board directly?

634


What are the disadvantages of c language?

624


What is the stack in c?

728


find the sum of two matrices and WAP for it.

642


Explain which function in c can be used to append a string to another string?

596


Explain what is the best way to comment out a section of code that contains comments?

728