Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!batcomputer!llenroc!cornell!uw-beaver!rice!fontenot From: fontenot@rice.edu (Dwayne Jacques Fontenot) Newsgroups: comp.lang.c Subject: doing nasty things with internal static variables Message-ID: <1991Mar19.183920.18911@rice.edu> Date: 19 Mar 91 18:39:20 GMT References: <1991Mar19.164037.7421@intellistor.com> Sender: news@rice.edu (News) Reply-To: fontenot@comet.rice.edu (Dwayne Jacques Fontenot) Distribution: usa Organization: Rice University, Houston, Texas Lines: 23 Keywords: C, crossreference Hello, I have found myself doing this because it works, but I am curious if it is a common practice or if it is highly likely to get me into trouble: 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). I have used this on ANSI compilers on diverse architectures with no problems yet, and it's just so damned *convenient*. Thank you for your time, Dwayne Fontenot (fontenot@comet.rice.edu)