Pointers, Structs, and Arrays
Larry Jones
scjones at sdrc.UUCP
Thu May 11 07:42:26 AEST 1989
In article <743 at mccc.UUCP>, pjh at mccc.UUCP (Pete Holsberg) writes:
> struct foo
> {
> char bar[20];
> } list[100];
>
> *list[i].bar = '\0';
>
> Now I know that the last line points to the first character in the bar array
> In each struct variable, but how? If bar = &bar[0], how so the '*' and the
> '&' "get together" to make the last line equivalent to
> list[i].bar[0]
Well, the problem is that bar is NOT equivalent to &bar[0].
Rather, list[i].bar is equivalent to &list[i].bar[0], which
should make it easier to see how the "*" and the "&" get
together.
What you have to realize is that bar DOES NOT EXIST -- since it
is a member of a structure, it only exists as part of an actual
instance of the structure and must be referenced as such.
----
Larry Jones UUCP: uunet!sdrc!scjones
SDRC scjones at SDRC.UU.NET
2000 Eastman Dr. BIX: ltl
Milford, OH 45150-2789 AT&T: (513) 576-2070
"You can't get a body like mine in a bottle --
unless you push REAL HARD." - Judy Tenuta / Dr. Pepper
More information about the Comp.lang.c
mailing list