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

if (i = 0)printf ("True"); elseprintf("False"); Under what conditions will the above print out the string "True" a) Never b) Always c) When the value of i is 0 d) all of the above

705


Why is c known as a mother language?

740


What is build process in c?

643


What are dangling pointers? How are dangling pointers different from memory leaks?

617


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

654






How does struct work in c?

604


How macro execution is faster than function ?

660


what is a function method?give example?

1910


How can variables be characterized?

1645


What is extern variable in c with example?

534


What are keywords c?

596


Why does not c have an exponentiation operator?

624


Which function in C can be used to append a string to another string?

641


Can we use any name in place of argv and argc as command line arguments?

606


What is union in c?

630