🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: C question

#39451
From: Jeff Beadles
Date: Thu, 14 Dec 1989 18:26
45 lines
2079 bytes
In article <31352@pbhya.PacBell.COM>
  dbsuther@PacBell.COM (Daniel B. Suthers) writes:
>In article <875@lzaz.ATT.COM>
>  hcj@lzaz.ATT.COM (HC Johnson) writes:

>>you can have char *fred[] = "hello";
>>
>>but not 
>>char fred[] = "hello";
>
>Mr. Johnson is correct; to use the second form you must use the form
>static char fred[] = "HELLO"
>or the way he has it set up as an array of pointers (sometimes).  If
>you set it up as an array of pointers it will only work if the machine
>uses a linear address scheme. 

[in all of this, the use of "static" is optional. ]

char *fred = "Hello";
is valid C practice. 

char *fred = "Hello";

is IDENTICAL to

char fred[] = "Hello";

Either way, "fred" points to an array of char's.
If your compiler does not handle this properly, then your "compiler"
should be replaced with a REAL C compiler.  (1/2 :-)

with the declaration char *fred[], (this is the same as char **fred; )
"fred" point to an array of pointers to POINTERS to characters.  This should
NEVER be defined like: 'char *fred[] = "Hello"; '


>For those who have not seen it yet, the newsgroup "comp.unix.wizards" is
>very helpful for those just starting in C and unix.  They are always eager
>to lend support.  The newsgroup seems to be not so much for the wizards as 
>it is for the neophytes who don't have a wizard handy to help them.
>

Noooooooo!!!!  This group is NOT for neophytes.  If you have C questions,
please use comp.lang.c.  If you have unix questions, use comp.unix.questions.
Please don't clutter comp.unix.wizards with beginners questions.
Technical Details
Message-ID: <5651@orca.wv.tek.com>
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!zephyr.ens.tek.com!orca.wv.tek.com!quark!jeff
References: <8912050802.AA12717@ucbvax.Berkeley.EDU> <875@lzaz.ATT.COM> <31352@pbhya.PacBell.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!uunet!zephyr.ens.tek.com!orca.wv.tek.com!quark!jeff
From: jeff@quark.WV.TEK.COM (Jeff Beadles)
Newsgroups: comp.sys.atari.st
Subject: Re: C question
Message-ID: <5651@orca.wv.tek.com>
Date: 14 Dec 89 18:26:06 GMT
References: <8912050802.AA12717@ucbvax.Berkeley.EDU> <875@lzaz.ATT.COM> <31352@pbhya.PacBell.COM>
Sender: nobody@orca.wv.tek.com
Reply-To: jeff@quark.WV.TEK.COM (Jeff Beadles)
Lines: 45