A89: Re: Re: Just subscribed... my first question


[Prev][Next][Index][Thread]

A89: Re: Re: Just subscribed... my first question




Hi!

> It seems clearer now that I've had a good 8 hours of sleep. So static can
> save you space by leaving out the initialization code for an array if the
> entire array will be stored in the file anyway. In that case, the use of
> static will make the array variable point straight to the array in the
file
> rather than copying the array each time the function is called. However,
> with data initialized to zero then the whole array need not be stored in
the
> file, so using static will force the whole array to be stored and will
> increase file size.

Exactly :-)

> So can static be used to make a variable persistent so that it maintains
> it's value when the program is run again?

Yes. I used static arrays to keep high scores in cblaster and creversi.
Note that it will not work if the program is archived, because each time
you run the archived program, it is copied from archive memory to RAM,
so it content will be refreshed each time.

Zeljko