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
Is array name a pointer?
What is a good way to implement complex numbers in c?
#include
Is there a way to switch on strings?
find the output? void r(int a[],int c, int n) { if(c>n) { a[c]=a[c]+c; r(a,++c,n); r(a,++c,n); } } int main() { int i,a[5]={0}; r(a,0,5); for(i=0;i<5;i++) printf("\n %d",a[i]); getch(); }
What is the difference between malloc() and calloc()?
Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?
Give basis knowledge of web designing ...
What is the use of sizeof () in c?
a linearly ordered set of data elements that have the same structure and whose order is preserved in storage by using sequential allocation a) circular b) ordinary c) array d) linear list
swap 2 numbers without using third variable?
How can variables be characterized?
What would happen to X in this expression: X += 15; (assuming the value of X is 5)
What is structure padding in c?
int main() { Int n=20,i; For(i=0;i<=n;i--) { Printf(“-“); Return 0;