Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!lll-lcc!unisoft!hoptoad!academ!killer!jfh From: jfh@killer.UUCP (John Haugh) Newsgroups: comp.lang.c Subject: Re: static variables Message-ID: <972@killer.UUCP> Date: Mon, 8-Jun-87 12:31:06 EDT Article-I.D.: killer.972 Posted: Mon Jun 8 12:31:06 1987 Date-Received: Fri, 12-Jun-87 01:46:52 EDT References: <7653@brl-adm.ARPA> Organization: The Unix(tm) Connection, Dallas, Texas Lines: 35 Summary: No, the pointer is automatic. In article <7653@brl-adm.ARPA>, jfjr@mitre-bedford.arpa asks: > > Are character strings local to a function static?? > > given this > > int do_something() > { > char * some_string = "some string" > do_things; > return(some_int); > } > > is some_string static?? > > Jerry Freedman,Jr No, the default class in a function is automatic. The string that is used, "some string", I guess could be considered static since its life isn't only during function execution. However, the storage for some_string is undefined after do_something returns. [ Lots of garbage to get around 50% rule ... ] I wouldn't call this a "truly" static or "truly" automatic storage situation. You could return (some_string) if the return type was char pointer, and things would be fine (as opposed to if "some string" was in a character array that was automatic). But returning (&some_string) would be a no-no, where if some_string _were_ static you would be able to return its address without causing trouble. - John. Disclaimer: No disclaimer. Whatcha gona do, sue me?