freelanceprogrammers.org Forum Index » C

Storage Class


View user's profile Post To page top
cgroup_sakthi Posted: Thu Jan 06, 2005 1:00 pm


Joined: 06 Jan 2005

Posts: 2
Storage Class
HI,

itz about a storage class.as we know that the
storage classes are register,auto,static,extern.

so which of the classes will be given the highest
priority like order of operatores and where they
are
stored (i mean the memory like data segemnt,stack
like friend).

Regards
Sakthivel




__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
Reply with quote
Send private message
View user's profile Post To page top
raghughatage Posted: Fri Jan 07, 2005 8:01 pm


Joined: 07 Jan 2005

Posts: 2
Storage Class
Your first question, priority(precedence) of storage class
specifiers...
There is no question of priority here because u can use only one
such specifier in one declaration. ie, u cannot do anything like,

static register int i; /* this is an error */

And your second question, the storage location...

All auto variables are stored on the stack, more precisely in the
activation record of the function.
All register variables are same as auto, only that it recomends to
the compiler that, if it is possible place the variable in a
register. But it is solely up to the compiler to decide.
All static variable are stored in the initilized data segment of the
program.
Extern variable declaration do not allocate any memory. Hence no
question of storage. But if the extern variable is initilized in the
declaration then, it allocates memory again in the initilized data
segment.


Hope it is clear.
Raghavendra.


--- In Programmers-Town@yahoogroups.com, Sakthivel
Dhanabalakrishnanan <cgroup_sakthi@y...> wrote:
>
> HI,
>
> itz about a storage class.as we know that the
> storage classes are register,auto,static,extern.
>
> so which of the classes will be given the highest
> priority like order of operatores and where they
> are
> stored (i mean the memory like data segemnt,stack
> like friend).
>
> Regards
> Sakthivel
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
Booking Calendar - reservation calendar script
Land Surveying - total station instruments and equipments
China Wholesale - Electronics Products
Character Studio - Tutorials and Help