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


Please Help Members By Posting Answers For Below Questions

What are the uses of null pointers?

590


How are structure passing and returning implemented?

592


what is the diffrenet bettwen HTTP and internet protocol

1393


In C language, a variable name cannot contain?

745


Which driver is a pure java driver

994






how should functions be apportioned among source files?

627


what is the differnce between programing langauge and tool? is sas is a programing langauge r tool?

1906


What is nested structure with example?

625


What are pragmas and what are they good for?

577


How many parameters should a function have?

668


How do c compilers work?

611


What is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?

733


What does volatile do?

567


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.

720


Explain about C function prototype?

611