Re: Static Variables



akhil.misra@xxxxxxxxx said:

where does a static variable inside a function get stored??

In random access memory, or "RAM" (or, if it's const, it might get put
into read-only memory, or "ROM").

where does it go in memory??

That's up to the implementation. It varies.

like Global goes in RAM,

Assuming you mean file scope objects with external linkage, yes, they're
stored in RAM (unless they're const, in which case they might go into
ROM).

Local variable goes on Stack...

Assuming you mean automatic objects, they're stored in RAM, unless
they're const, in which case they might go into ROM. They might be
incorporated into some kind of a stack structure, or they might not.
It's up to the implementation.

but how does static variable takes place in memory??

It goes into RAM (or, if it's const, it might go into ROM). The precise
details depend on the implementation.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
.



Relevant Pages

  • Re: Volatile const
    ... Standard that defines the C language, ... the const qualifier, so it is not really "variable" in that sense. ... The answer, which is what I think you mean by "Ans" is not ROM or RAM, ... not be modified through that pointer. ...
    (comp.std.c)
  • Re: Larkin, Power BASIC cannot be THAT good:
    ... part of "const int" and therefore actually allocated memory and stored the value, fetching it again every time it was needed. ... A lot of the older compilers did that copy to ram even when they purported to generate code for embedded systems. ... And you can be sure that no attempt by the CPU to trash a ROM value will ever succeed. ... You could tell it was in big trouble if the user register bank was in ROM where incrementing the program counter doesn't work any more. ...
    (sci.electronics.design)
  • Re: const int value changing....
    ... > when a 'const int ' is declared, where is it been created(in RAM?) ... the compiler won't allow you to modify a const variable. ...
    (comp.lang.c)
  • Re: const int value changing....
    ... > when a 'const int ' is declared, where is it been created ... What is RAM? ... declaring a variable does not ...
    (comp.lang.c)
  • Re: Static Variables
    ... You mean my implementation using pairs of goldfish to store each bit is not a conforming implementation? ... Assuming you mean automatic objects, they're stored in RAM, unless they're const, in which case they might go into ROM. ...
    (comp.lang.c)