Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!usc!snorkelwacker.mit.edu!hsdndev!cmcl2!adm!smoke!gwyn From: gwyn@smoke.brl.mil (Doug Gwyn) Newsgroups: comp.lang.c Subject: Re: doing nasty things with internal static variables Message-ID: <15526@smoke.brl.mil> Date: 20 Mar 91 21:30:19 GMT References: <1991Mar19.164037.7421@intellistor.com> <1991Mar19.183920.18911@rice.edu> Organization: U.S. Army Ballistic Research Laboratory, APG, MD. Lines: 17 In article <1991Mar19.183920.18911@rice.edu> fontenot@comet.rice.edu (Dwayne Jacques Fontenot) writes: -char *foo() -{ - static char string[64]; - ... - return(string); -} -I am concerned about this because though I know that that static variable -is guaranteed to always be there for the function containing it, it is -not really guaranteed to be there (in memory) at any other time -(correct me if I'm wrong). There's nothing particularly wrong with that usage. Objects having static storage duration exist throughout program execution. Now, if you had omitted the "static" storage-class specifier, the array would have been an automatic variable, and auto storage does "evaporate" upon leaving the block in which it is declared.