Hi,
I'm wondering of what type a structure is. Of course, it is a
_structure_, but an array isn't an _array_ either. So of what type is
a structure? I'd say a pointer, am I right?
No.
Perhaps it would help us if you elaborated why you think that an
array is not an array. Otherwise this not so helpful answer certainly
isn't a not so helpful answer.
Guess: You mean an array is not of type "array" but of type "array of
<sometype>".
A structure is exactly of the type you stated it is, that is:
struct {
int x;
char y;
} example;
is of the type "Structure consisting of (in that order) one int,
accessible as x, and one char, accessible as y".
A pointer of type "pointer to <sometype>" contains (if properly
initialized) either NULL or a valid address of an object of type
sometype.
A structure's type is not "pointer".
Note that these explanations are not formally correct; probably
someone else will elaborate or correct what I said.
But I think this helps you more than me posting the respective
parts of the standard:
"6.2.5#20, second item:
A structure type describes a sequentially allocated nonempty set of
member objects (and, in certain circumstances, an incomplete array),
each of which has an optionally specified name and possibly distinct type."
"6.2.7#1
Tw o types have compatible type if their types are the same. Additional
rules for determining whether two types are compatible are described in
6.7.2 for type specifiers, in 6.7.3 for type qualifiers, and in 6.7.5
for declarators.46) Moreover, two structure, union, or enumerated types
declared in separate translation units are compatible if their tags and
members satisfy the following requirements: If one is declared with a
tag, the other shall be declared with the same tag. If both are complete
types, then the following additional requirements apply: there shall be
a one-to-one correspondence between their members such that each pair of
corresponding members are declared with compatible types, and such that
if one member of a corresponding pair is declared with a name, the other
member is declared with the same name. For two structures, corresponding
members shall be declared in the same order. For two structures or
unions, corresponding bit-fields shall have the same widths. For two
enumerations, corresponding members shall have the same values."
Look up the FAQ for pointers, structures and unions as well as types
to help you along:
http://www.eskimo.com/~scs/C-faq/top.html
You can also google for N869, the last C99 draft, which is freely
available. There you can look for struct type and compatibility.
Cheers
Michael