Difference between "char *arr" and "char arr[]"
Sean Fagan
seanf at sco.COM
Thu Sep 27 07:05:12 AEST 1990
In article <ENAG.90Sep25005953 at hild.ifi.uio.no> enag at ifi.uio.no (Erik Naggum) writes:
>Rather, "char arr[14]" declares an array, but "extern char arr[]" only
>declares that "arr" is some constant pointer the value of which is to
>be resolved by the linker.
*NO NO NO NO*!
'extern char arr[]' does *not* declare, in any way, shape, or form, a
pointer.
What it *does* declare is the label of a block of memory (size currently
unknown), which will be (hopefully) resolved at link time.
The difference between
extern char arr[];
and
extern char *ptr;
is that the first one is not indirected to get the address; the other one
is. That is, ptr is actually a double-indirect variable: one indirection
to get its value, and another one to dereference it. arr, on the other
hand, is just indirected once, to get it's value (which is arr[0]).
--
-----------------+
Sean Eric Fagan | "Never knock on Death's door: ring the bell and
seanf at sco.COM | run away! Death really hates that!"
uunet!sco!seanf | -- Dr. Mike Stratford (Matt Frewer, "Doctor, Doctor")
(408) 458-1422 | Any opinions expressed are my own, not my employers'.
More information about the Comp.lang.c
mailing list