What are Storage Classes in C ?

Answers were Sorted based on User's Feedback



What are Storage Classes in C ?..

Answer / babu

There are two storage classes : Automatic and Static.

Automatic objects are local to block,and are discarded on
exit from the block.Declaration with in a block create
automatic objects if no storage class spections is
mentioned , or if the auto specifier is used.Object
declared as register are automatic,and are (if Possible)
stored in fast registers of the machine.

Static obj may be local to a block or external to all
blocks,but in either case retain their values across exit
from and reentry to function and blocks.Within a block
including a block that provides the code for a function,
static objects are declared with the keyword Static.
The objects declared outside all blocks,at the same level
as function definitions,are always static keyword;this
gives them Internal Linkage.
They become global to an entire program by omitting an
explicit storage class ,or by using keyword Extern;this
gives external linkage.

Is This Answer Correct ?    44 Yes 166 No

What are Storage Classes in C ?..

Answer / vijoeyz

C has three types of storage: automatic, static and
allocated.

Variable having block scope and without static specifier
have automatic storage duration.

Variables with block scope, and with static specifier have
static scope. Global variables (i.e, file scope) with or
without the the static specifier also have static scope.

Memory obtained from calls to malloc(), alloc() or realloc()
belongs to allocated storage class.

--
http://www.geocities.com/vijoeyz/faq/



Is This Answer Correct ?    27 Yes 282 No

Post New Answer

More C Interview Questions

can we implement multi-threads in c.

0 Answers  


What are the average number of comparisons required to sort 3 elements?

2 Answers   DRDO,


I need testPalindrome and removeSpace #include <stdio.h> #define SIZE 256 /* function prototype */ /* test if the chars in the range of [left, right] of array is a palindrome */ int testPalindrome( char array[], int left, int right ); /* remove the space in the src array and copy it over to the "copy" array */ /* set the number of chars in the "copy" array to the location that cnt points t */ void removeSpace(char src[], char copy[], int *cnt); int main( void ) { char c; /* temporarily holds keyboard input */ char string[ SIZE ]; /* original string */ char copy[ SIZE ]; /* copy of string without spaces */ int count = 0; /* length of string */ int copyCount; /* length of copy */ printf( "Enter a sentence:\n" ); /* get sentence to test from user */ while ( ( c = getchar() ) != '\n' && count < SIZE ) { string[ count++ ] = c; } /* end while */ string[ count ] = '\0'; /* terminate string */ /* make a copy of string without spaces */ removeSpace(string, copy, &copyCount); /* print whether or not the sentence is a palindrome */ if ( testPalindrome( copy, 0, copyCount - 1 ) ) { printf( "\"%s\" is a palindrome\n", string ); } /* end if */ else { printf( "\"%s\" is not a palindrome\n", string ); } /* end else */ return 0; /* indicate successful termination */ } /* end main */ void removeSpace(char src[], char copy[], int *cnt) { } int testPalindrome( char array[], int left, int right ) { }

0 Answers  


int main() { int i=-1,j=-1;k=0,l=2,m; m=i++&&j++&&k++||l++; printf("%d%d%d%d%d",i,j,k,l,m); }

3 Answers   HCL,


In which mode we open the file for read,write and append also in c ? a)W b)w+ c)r+ d)a

2 Answers   BitWise,






Write a program that takes three variables(a,b,c) in as separate parameters and rotates the values stored so that value a goes to b,b,to c and c to a

7 Answers  


Apart from dennis ritchie who the other person who contributed in design of c language.

0 Answers  


Write a C program that computes the value ex by using the formula ex =1+x/1!+x2/2!+x3+3!+………….

1 Answers  


What are the different types of errors?

0 Answers  


Name the language in which the compiler of "c" in written?

3 Answers   Bajaj,


How do you initialize pointer variables?

0 Answers  


What are keywords c?

0 Answers  


Categories