Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!sri-spam!ames!necntc!cullvax!drw From: drw@cullvax.UUCP Newsgroups: comp.lang.c Subject: static variables Message-ID: <1249@cullvax.UUCP> Date: Thu, 4-Jun-87 10:54:01 EDT Article-I.D.: cullvax.1249 Posted: Thu Jun 4 10:54:01 1987 Date-Received: Sat, 6-Jun-87 07:34:23 EDT Organization: Cullinet Software, Westwood, MA, USA Lines: 40 jfjr@mitre-bedford.arpa writes: > Are character strings local to a function static?? > > int do_something() > { > char * some_string = "some string" > do_things; > return(some_int); > } > > is some_string static?? No, it's automatic. But the value that it is initialized to is a pointer to a static object. Consider, char *p; int do_something(x) int x; { char *some_string = "some string"; if (x) { p = some_string; some_string = malloc(...); } else printf("%d", p == some_string); } This is a valid program, and if you call do_something(1) and then do_something(0), you get "1" for output. Dale -- Dale Worley Cullinet Software UUCP: ...!seismo!harvard!mit-eddie!cullvax!drw ARPA: cullvax!drw@eddie.mit.edu Un*x (a generic name for a class of OS's) != Unix (AT&T's brand of such)