c answer: THANKS
fjh at cord.UUCP
fjh at cord.UUCP
Thu Jul 17 13:34:19 AEST 1986
I wish to thank everyone that answered my question. The following
is a very clear explanation. The usage of A rather than &A[0] for arrays
had me blinded. Thanks.
> From ulysses!utah-cs!b-davis Wed Jul 16 19:39 EDT 1986
> Date: Wed, 16 Jul 86 17:36:32 MDT
> From: ulysses!utah-cs!b-davis (Brad Davis)
> Subject: Re: C question
> Message-Id: <8607162336.AA02526 at utah-cs.ARPA>
> Received: by ulysses.UUCP; Wed, 16 Jul 86 19:38:13 edt
> Received: by utah-cs.ARPA (5.31/4.40.2)
> id AA02526; Wed, 16 Jul 86 17:36:32 MDT
> Received: from ulysses.UUCP by lc/garage/cord.DK; 8607162339
> To: cord!fjh
> Newsgroups: net.lang.c
> In-Reply-To: <306 at cord.UUCP>
> Organization: University of Utah VCIS Group
> Cc:
> Status: R
>
> In article <306 at cord.UUCP> you write:
> >What is the difference between:
> >extern char *A;
> >and
> >extern char A[];
> >
> >If you do: printf("A=%s\n",A);
> >the first causes a core dump, the second works.
> >
> >I thought pointers and arrays were equivalent?
> NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO, NO :-)
>
> The first says that A is a pointer. On a VAX that means that the
> four bytes A+0, A+1, A+2, and A+3 are made into a pointer to a char.
> The second says that A is an array. On a VAX that means that some
> number of bytes after A (A+0, A+1, A+2, and on up to A+whatever)
> are characters.
> --
> Brad Davis {ihnp4, decvax, seismo}!utah-cs!b-davis
> b-davis at utah-cs.ARPA
> One drunk driver can ruin your whole day.
>
--
<*> Fred Hirsch <*> AT&T Bell Laboratories <*> ihnp4!cord!fjh <*>
More information about the Comp.lang.c
mailing list