Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!amd!markg From: markg@amd.UUCP Newsgroups: comp.lang.c Subject: Re: static variables Message-ID: <4077@amd.UUCP> Date: Thu, 4-Jun-87 19:47:49 EDT Article-I.D.: amd.4077 Posted: Thu Jun 4 19:47:49 1987 Date-Received: Sat, 6-Jun-87 11:42:06 EDT References: <7653@brl-adm.ARPA> <4064@amd.UUCP> <183@inco.UUCP> Reply-To: markg@amd.UUCP (Mark Gorlinsky) Organization: Advanced Micro Devices Lines: 33 In article <183@inco.UUCP> mack@inco.UUCP (Dave Mack) writes: -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!!!!!!!!! -> -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: > char *s = "Hello"; > static char *s2 = "World!"; > > Dave Mack (from Mack's Bedroom :<) > McDonnell Douglas-Inco, Inc. You are comparing apples to oranges or is that pointers to strings. Re-read the the orginial article. One question was, "Are character strings local to a function static??" The answer is YES!!! If you're not sure why, read K&R pg 80. The other question asked, "is some_string static?", is NO. Read carefully. Thank you. -- Mark Gorlinsky - AMD Processor Products Division/APPS SQA UUCP: {decwrl,ihnp4,allegra}!amd!markg AT&T: (408) 982-7811 DISCLAIMER: My opinions are mine, not my employers.