Re: Where is a static variable stored?
- From: "Jack" <junw2000@xxxxxxxxx>
- Date: 14 Jul 2006 11:27:54 -0700
Michael Mair wrote:
Jack schrieb:
Thanks.
You're welcome.
Please write/repeat your question in the message text -- there
are newsreaders which do not show subject and message text at
the same time.
Your question: "Where is a static variable stored?" has no
standard C answer.
Variables with static storage duration "live" throughout the
programme's lifetime. Whether they are stored all or only part
of the time in RAM, ROM, or registers is not specified -- they
have only to behave as if they were there the whole time.
This may not be the answer to what you _wanted_ to ask; please
be precise in your questions.
I think for a static variable defined out of any functions, i.e., it is
a global variable, it is located in the data segment of the program.
How about a static variable defined within a function? it is a local
variable. Is it located at the stack?
Thanks.
.
- Follow-Ups:
- Re: Where is a static variable stored?
- From: Al Balmer
- Re: Where is a static variable stored?
- From: Malcolm
- Re: Where is a static variable stored?
- From: Walter Roberson
- Re: Where is a static variable stored?
- From: jjf
- Re: Where is a static variable stored?
- From: Keith Thompson
- Re: Where is a static variable stored?
- From: Barry Schwarz
- Re: Where is a static variable stored?
- From: Walter Roberson
- Re: Where is a static variable stored?
- References:
- Where is a static variable stored?
- From: Jack
- Re: Where is a static variable stored?
- From: Michael Mair
- Where is a static variable stored?
- Prev by Date: Re: Looking for a C textbook with emphasis on data types
- Next by Date: Re: After read a whole OS written by C, someone asks `What is the advantage of C'
- Previous by thread: Re: Where is a static variable stored?
- Next by thread: Re: Where is a static variable stored?
- Index(es):
Relevant Pages
|