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
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
Why is c known as a mother language?
What is build process in c?
What are dangling pointers? How are dangling pointers different from memory leaks?
How can I avoid the abort, retry, fail messages?
How does struct work in c?
How macro execution is faster than function ?
what is a function method?give example?
How can variables be characterized?
What is extern variable in c with example?
What are keywords c?
Why does not c have an exponentiation operator?
Which function in C can be used to append a string to another string?
Can we use any name in place of argv and argc as command line arguments?
What is union in c?