1. declaration.... its just an acknowledgement to the compliler about the blueprint of some entity. Be it a varaible or a funtion.By putting blue print i just mean that..the necessary information(characteristics) about the entity. so here complier doesnt allocate any memory to the entity(Remember functions also need memory not only variables). It just takes the information and ok..nothing is done from compiler side as far as allocation issues are concerned!!.So the entity declared doesnt exits in memory till now. so what to do , our target is to use those variables and functions...so here we come up with definitions.
2.Definition...
This is the thing which brings some enitity into its real existance.The value is given to the variable(if u do it explicitly then its ok , your value will be assigned to the variable otherwise you will get the garbage value). So here the memory is allocated for the entity and from hereafter it is present in the memory.
lets observe it in a program.
twoterms.c
#include...........
/*include the things you need
,i am not writting them here*/
extern int globalvalue;//this the case of pure variable declaration
void myfunction1(int,float);
/*A function declaration...as there isnt any body for the function ,so no need of memory, obviosuly compiler doesnt need to allocate any memory for this one, very clever!!!*/
void main()
{
int i;//remember its a declration as well as definition
printf("the value of i is %d",i)//garbage value will be dsiplayed
int i2=0;//declaraions as well as initialization
}
1 comment:
all blogs r very nice keep it up:)
Post a Comment