Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!husc6!seismo!sundc!hadron!inco!mack From: mack@inco.UUCP Newsgroups: comp.lang.c Subject: Re: static variables Message-ID: <183@inco.UUCP> Date: Thu, 4-Jun-87 10:54:23 EDT Article-I.D.: inco.183 Posted: Thu Jun 4 10:54:23 1987 Date-Received: Sat, 6-Jun-87 07:52:01 EDT References: <7653@brl-adm.ARPA> <4064@amd.UUCP> Organization: McDonnell Douglas-INCO, McLean, VA Lines: 39 Summary: I think I disagree In article <4064@amd.UUCP>, markg@amd.UUCP (Mark Gorlinsky) writes: > In article <7653@brl-adm.ARPA> jfjr@mitre-bedford.arpa writes: > > > >Are character strings local to a function static?? > > Yes!!!!!!!!! > > Mark Gorlinsky - AMD Processor Products Division/APPS SQA I disagree. A static variable retains its value between function calls, while an initialized local variable is reinitialized on each call to the function. Try this code to see what I mean: #include main() { out(); out(); } out() { char *s = "Hello"; static char *s2 = "World!"; printf("%s %s\n",s,s2); s = "Goodbye"; s2 = "Mom"; } -- ------------------------------------------------------------------------------ Dave Mack (from Mack's Bedroom :<) McDonnell Douglas-Inco, Inc. DISCLAIMER: The opinions expressed 8201 Greensboro Drive are my own and in no way reflect the McLean, VA 22102 views of McDonnell Douglas or its (703)883-3911 subsidiaries. ...!seismo!sundc!hadron!inco!mack ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++