what is the difference between declaration and definition
of a variable or function ?
Answer Posted / michael scofield
definition defines the memory area ( allocates the memory ) for the variable and the declaration tells about the signature of the variable ( type and size to be considered). definition occures once through the program( memory is allocated once ), but the declaration can occur many times.
OR For a variable, the definition is the statement that actually allocates memory. For example, the statement:
long int var;
is a definition. On the other hand, an extern reference to the same variable:
extern long int var;
is a declaration, since this statement doesn�t cause any memory to be allocated. Here�s another example of a declaration:
typedef MyType short;
Is This Answer Correct ? | 4 Yes | 0 No |
Post New Answer View All Answers
What are the uses of null pointers?
How are structure passing and returning implemented?
what is the diffrenet bettwen HTTP and internet protocol
In C language, a variable name cannot contain?
Which driver is a pure java driver
how should functions be apportioned among source files?
what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?
What is nested structure with example?
What are pragmas and what are they good for?
How many parameters should a function have?
How do c compilers work?
What is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?
What does volatile do?
Find the second largest element in an array with minimum no of comparisons and give the minimum no of comparisons needed on an array of size N to do the same.
Explain about C function prototype?