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
Explain what is a static function?
How to draw the flowchart for structure programs?
Explain how do you print only part of a string?
What is static memory allocation? Explain
What is a protocol in c?
Simplify the program segment if X = B then C ← true else C ← false
Can we declare function inside main?
Explain null pointer.
diff between exptected result and requirement?
What’s the special use of UNIONS?
What is the general form of #line preprocessor?
What is the difference between a free-standing and a hosted environment?
Describe the difference between = and == symbols in c programming?
What's the difference between constant char *p and char * constant p?
Can variables be declared anywhere in c?