Nick Keighley
11/5/2009 1:03:00 PM
On 5 Nov, 12:29, phaedrus <orion.osi...@virgin.net> wrote:
> On Nov 5, 12:56 pm, bert <bert.hutchi...@btinternet.com> wrote:
> > No, I don't think that's right. An array can't store data; the
> > data is stored in its individual ELEMENTS. A struct can't store
> > data;
the struct declaration declares a type
> > the data is stored in its individual FIELDS. The elements
> > of the array are referenced by their subscripts; the fields of
> > the struct are referenced by their names. There's a difference,
> > but I think it's a much smaller difference than you think it is.
>
> OK, point taken. Let me clarify, then.
>
> The data in an array is stored in its elements.
> The data for a struct is stored in the member fields of a structure
> VARIABLE.
>
> Is that correct?
arrays are variables too...
There are types
int, struct S {float f}
there are declarations, which describe what something is but without
setting aside storage
extern int i;
extern int a[];
extern struct S s;
and there are definitions which set aside store
int i;
int a [10];
struct S s;
the slight confusion is that "naked" array types are hardly used (i'm
not even sure if they exist).
typedefs add an additional layer of confusing as despite their name
they don't define types but type aliases.