We often get confused between declaration and definition. Don't worry. After this article, It will not happen again. Trust me.
Definition :- only once and consumes memory.
Declaration :- can be multiple times and does not consume memory.
Or We can say :-
a definition is the special kind of declaration that fixes the storage for an object
For Example :-
#include<stdio.h>
#include<conio.h>
int x[2]; // definition, it consumes memory
void main()
{
clrscr();
printf("Hello");
extern int x[]; // declaration and hence doesn't consumes memory
printf("hello");
getch();
}
Here in declaration, there is no need of even specifying the size. Because m/y is already allotted to it.
0 comments: