🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.atari.st
Article #39453

Re: C question

#39453
From: dennis pixton
Date: Thu, 14 Dec 1989 20:17
27 lines
1810 bytes
In article <5651@orca.wv.tek.com> jeff@quark.WV.TEK.COM (Jeff Beadles) writes:

>   char *fred = "Hello";
>
>   is IDENTICAL to
>
>   char fred[] = "Hello";

Ummm, no.  One declares and initializes a pointer, the other declares and
initializes an array of characters.  For a discussion see K&R, second
edition, pp. 104 & 219.  In particular, fred[0] = 'h' or *fred = 'h' is
legal for the second declaration but not for the first (according to ANSI),
while fred = "Goodbye" is legal for the first but not for the second.

The original posting in this thread referred to initialization of an
_automatic_ array.  This was forbidden by the original K&R but is permitted
by ANSI C.  See K&R, second edition, p. 219.

--
Dennis Pixton
Department of Mathematical Sciences     (607) 777-4239
SUNY-Binghamton                         dennis@math.binghamton.edu
Binghamton, NY  13901                   dpixton@bingvaxa.bitnet
Dennis Pixton
Department of Mathematical Sciences     (607) 777-4239
SUNY-Binghamton                         dennis@math.binghamton.edu
Binghamton, NY  13901                   dpixton@bingvaxa.bitnet
Technical Details
Message-ID: <DENNIS.89Dec14151721@phyllis.math.binghamton.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!leah!bingvaxu!phyllis.math.binghamton.edu!dennis
References: <8912050802.AA12717@ucbvax.Berkeley.EDU> <875@lzaz.ATT.COM> <31352@pbhya.PacBell.COM> <5651@orca.wv.tek.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!leah!bingvaxu!phyllis.math.binghamton.edu!dennis
From: dennis@phyllis.math.binghamton.edu (dennis pixton)
Newsgroups: comp.sys.atari.st
Subject: Re: C question
Message-ID: <DENNIS.89Dec14151721@phyllis.math.binghamton.edu>
Date: 14 Dec 89 20:17:21 GMT
References: <8912050802.AA12717@ucbvax.Berkeley.EDU> <875@lzaz.ATT.COM>
 <31352@pbhya.PacBell.COM> <5651@orca.wv.tek.com>
Sender: usenet@bingvaxu.cc.binghamton.edu
Organization: Dept of Math Sci, SUNY-Binghamton
Lines: 27
In-reply-to: jeff@quark.WV.TEK.COM's message of 14 Dec 89 18:26:06 GMT