"Eric Sosman" writes:
vim wrote:
>hello guys
plz tel me the differances between global static and local static.
If possible with examples
Please explain what you mean by "global static" and "local
static," because the Standard that defines the C language does
not use either phrase.
I normally leave such question to the language mavens.
A variable declared as static within a function preserves information
between successive calls to that function. For example, a random number
generator(1) can preserve the seed to be used to generate the next number.
A variable or function declared as static external to any function "hides"
the item from code in other source files(2), thus preventing inadvertent -
or perhaps malicious, usage. By default functions are "known" everywhere
and variables *can* be known by use of an extern qualifier(3) by the
*receiver*, not the giver.
Function declarations *can* be made within a function, but it is a rarely
used style. My guess is that the addition of static would have no effect.
.................
(1) Yes I know the generator does not generate random numbers. Get a life
fer crissakes!!
(2) Yes I know the dammed thing is called a translation unit!
(3) The proper name may not actually be "qualifier". Despite that, a
person speaking ordinary English would understand.