From: "John M. Aldrich" Newsgroups: comp.os.msdos.djgpp Subject: Re: Question on pointers and arrays Date: Mon, 17 Feb 1997 19:35:18 -0800 Organization: Two pounds of chaos and a pinch of salt Lines: 44 Message-ID: <33092376.1E3@cs.com> References: <32f92a6c DOT 0 AT ntnews DOT compusmart DOT ab DOT ca> <32FA7146 DOT 3883 AT cam DOT org> <32fa7242 DOT 998097 AT news DOT walrus DOT com> <5dsgcv$5m4 AT star DOT cs DOT vu DOT nl> <3303DF62 DOT 21E0 AT cs DOT com> <5e1f1u$m07 AT star DOT cs DOT vu DOT nl> Reply-To: fighteer AT cs DOT com NNTP-Posting-Host: ppp204.cs.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Ruiter de M wrote: > > John M. Aldrich (fighteer AT cs DOT com) wrote: > : Ruiter de M wrote: > : > > : > : >char string[5]="abcde" and > : > : >char *string="abcde" are equivalent. > > That's not what _I_ (mdruiter) wrote :) Sorry. I thought the double quote would make it obvious, but the previous poster clipped out the attribution line (or I did; I forget now). :) > Yes, you say _static_ data space. Which means it is not at all writable. > For instance: > ----- [example snipped] > Not unpredictable at all. string1 is writable, string2 is not. Or am I getting > something wrong? No, but apparently this sort of thing is system-specific. When you do that with DJGPP in DOS, it works fine (although it still is very unsafe). > Maybe you mean there is no difference in _pointer_, which I think is not > true either. [more snippage] > test.c: In function `main': > test.c:11: incompatible types in assignment > ----- > No error for string2, error for string1. > So. Different pointers to different memory. Or am I getting it wrong again? No, here you are saying exactly what I said, later in my response. But however you say it, it's still a bad idea to write into static data space, and illegal to attempt to modify an array identifier. :) -- --------------------------------------------------------------------- | John M. Aldrich, aka Fighteer I | fighteer AT cs DOT com | | * Proud user of DJGPP! * | http://www.cs.com/fighteer | | ObJoke: If Bill Gates were a robber, not only would he | | shoot you, but he'd send you a bill for the bullets. | ---------------------------------------------------------------------