Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!sri-spam!ames!amdahl!nsc!nsta!instable!amos From: amos@instable.UUCP (Amos Shapir) Newsgroups: comp.lang.c Subject: Re: Local string storage -- *guaranteed* static? Message-ID: <814@instable.UUCP> Date: Fri, 5-Jun-87 10:21:43 EDT Article-I.D.: instable.814 Posted: Fri Jun 5 10:21:43 1987 Date-Received: Tue, 9-Jun-87 07:16:12 EDT References: <7690@brl-adm.ARPA> Reply-To: amos%nsta@nsc.com (Amos Shapir) Distribution: world Organization: National Semiconductor (Israel) Ltd. Home of the 32532 Lines: 20 Summary: All that is char * is not a string Hdate: 8 Sivan 5747 To put this matter to sleep once and for all: func() { char *str1 = "some string"; static char *str2 = "another string"; ... } str1 and str2 are *not* strings as defined by K&R p.181, they are char pointers, str1 is automatic and str2 static. Whatever is between the "'s is a string, i.e. an unnamed static array of chars, the address of whose first element (0th, actually) is assigned to str1 or str2. The assignment to str2 is done at compile time (or once at run time), the assignment to str1 is done on every call to func() (note that only the *address* of the string is assigned; if you change its *contents*, they remain changed). -- Amos Shapir National Semiconductor (Israel) 6 Maskit st. P.O.B. 3007, Herzlia 46104, Israel Tel. (972)52-522261 amos%nsta@nsc.com @{hplabs,pyramid,sun,decwrl} 34 48 E / 32 10 N