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
define string ?
how can I convert a string to a number?
Differentiate between declaring a variable and defining a variable?
Is c high or low level?
What does void main () mean?
Which is best linux os?
What is the difference between Printf(..) and sprint(...) ?
What are the advantages of union?
a program that can input number of records and can view it again the record
Differentiate between the = symbol and == symbol?
Does sprintf put null character?
What are the rules for identifiers in c?
What is pass by reference in functions?
Differentiate between static and dynamic modeling.
List out few of the applications that make use of Multilinked Structures?