What are Storage Classes in C ?

Answer Posted / monika

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 ?    31 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is #define used for in c?

615


What is the value of a[3] if integer a[] = {5,4,3,2,1}?

672


Why is c so powerful?

687


How can I avoid the abort, retry, fail messages?

663


What's the total generic pointer type?

614






What is omp_num_threads?

585


By using C language input a date into it and if it is right?

574


What is time complexity c?

568


1. Write a function to display the sum of two numbers in the following ways: By using (i) pass by value (ii) pass by address a. function with argument and with return value b. function with argument and without return value c. without argument , with return value d. without argument , without return value Note: Use pass by address.

2337


in ‘C’ language for Matrix Multiplication fails” Introspect the causes for its failure and write down the possible reasons for its failure.

7410


When should a type cast be used?

575


What is the use of parallelize in spark?

576


Why isn't it being handled properly?

645


What is use of integral promotions in c?

666


Do pointers store the address of value or the actual value of a variable?

610