Ok to set the things straight
there are three kind of scope ( place in the code where variable can be accesed )
extern : entire prog
auto : in the block where its defined.
static : now there is a nice twist here in words. I will say if defined inside a funtion it has a auto scope.
But it you define it before a function then it has a scope there after but only in the file where its defined.
Now its life time utill when variable is having life.... fundu haan :)
Not like that it simply means that point of time when variable can be accessed.
Unfortunatly there is no keyword as scope to define life time.
Life time of static and extern variable is before main is called and utill program exits.
Life time of arguments and that of local variables it is from the point when funciton is called and untill function return.
Life time of dynamic allocated block is from the point when we issue malloc or calloc command to the point when we use free call.
No comments:
Post a Comment