Article View: comp.sys.atari.st
Article #6586Re: C question
From: HC Johnson
Date: Wed, 06 Dec 1989 00:44
Date: Wed, 06 Dec 1989 00:44
38 lines
1443 bytes
1443 bytes
In article <8912050802.AA12717@ucbvax.Berkeley.EDU>, S61304@PRIME-A.POLY-SOUTH-WEST.AC.UK (Rat) writes:
> (From "The Masked Rat Fink" "Computing and Informatics Yr4")
>
> Question.
>
> (This is probably a really silly one to any C wizards, but I'm only a BASIC
> wizard!)
>
> Why wont Sozobon, Lattice or any other C compiler I've tried compile the
> following, from K&R?
>
> main()
> $
> char fred[] = "Some string constant";
> <rest of routine>
>
>
> This has been confusing me for a while, as K&R (surely correct!) would
> seem to indicate that this is indeed permissible!
NO NO NO
you can have char *fred[] = "hello";
or
char fred[] = {'h','e','l','l','o','\0'};
but not
char fred[] = "hello";
char *fred[] is an array of pointers, the first points to the string "hello"
char fred[] is an array of chars, 6 in my example.
Howard C. Johnson
ATT Bell Labs
att!lzaz!hcj
hcj@lzaz.att.com
Technical Details
Message-ID:
<875@lzaz.ATT.COM>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!brutus.cs.uiuc.edu!apple!rutgers!att!dptg!lzaz!hcjReferences:
<8912050802.AA12717@ucbvax.Berkeley.EDU>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!pacific.mps.ohio-state.edu!zaphod.mps.ohio-state.edu!brutus.cs.uiuc.edu!apple!rutgers!att!dptg!lzaz!hcj From: hcj@lzaz.ATT.COM (HC Johnson) Newsgroups: comp.sys.atari.st Subject: Re: C question Summary: surely you mis quote K&R Message-ID: <875@lzaz.ATT.COM> Date: 6 Dec 89 00:44:15 GMT References: <8912050802.AA12717@ucbvax.Berkeley.EDU> Organization: AT&T ISL Lincroft NJ USA Lines: 38