Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!olivea!uunet!wuarchive!zaphod.mps.ohio-state.edu!think.com!compass!worley From: worley@compass.com (Dale Worley) Newsgroups: comp.lang.c Subject: Re: Why didn't ANSI make initialisation consistent ???? Message-ID: Date: 25 Apr 91 14:51:07 GMT References: <1991Apr24.141206.18103@grep.co.uk> Sender: root@compass.com Organization: Compass, Inc., Wakefield, MA, U.S.A. Lines: 35 In-reply-to: vic@grep.co.uk's message of 24 Apr 91 14:12:06 GMT In article <1991Apr24.141206.18103@grep.co.uk> vic@grep.co.uk (Victor Gavin) writes: I traced it back to my use of char *fred = "bert" Could anyone tell me whether the ANSI committee pondered over the problem of tidying up the inconsistencies of the C initializations ? Actually, initializations *are* consistent -- other than the object named in the declaration, an initialization *never* allocates memory. What is allocating the "extra" memory is the string literal "bert". String literals *always* allocate memory for themselves, except in the special case when they are used as the initializer for an array of chars. For instance, char *p; p = "1234"; allocates 5 bytes of memory to hold the string literal. Dale Worley Compass, Inc. worley@compass.com -- So you want to have a shameful affair? Yet, somehow you can't justify it? The next time you are contemplating a decision in which you are debating whether or not to go for the gusto, ask yourself this Important Question: How long will I be dead? With that perspective, you can now make a free, fearless choice to do just about any goddamned sneaky thing your devious little mind can think up. Go ahead. Have your fun. You're welcome. Go on. See you in Hell. --Matt Groening