Jon Dowland wrote:
Because sizeof is not really the size of the struct, it is
the distance between adjacent structs in an array.
Alignment forces the extra bytes


I'm not quite sure I get what you're saying here. Yes,
alignment pads out the structure. But I'm not sure where
arrays come into it :- sizeof(struct whatever) is applicable
to a single instance of a struct too.

What he's saying is that

        struct FredStruct Fred[2];
        ...
        sizeof(struct Fred[0])

is the same as

        (void *)(&Fred[1])-(void *)(&Fred[0])

Structures may get padding at the end precisely for this
reason. It is not obvious that this is the case when one
talks about a single instance.

Mike
--
p="p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
Oppose globalization and One World Governments like the UN.
This message made from 100% recycled bits.
You have found the bank of Larn.
I can explain it for you, but I can't understand it for you.
I speak only for myself, and I am unanimous in that!


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to