On 7/23/2010 8:31 AM, Tech Id wrote:
> struct pad1 {
> char c1;
> };
>
> struct pad2 {
> char c1;
> int x;
> };
>
>
> struct pad3 {
> char c1;
> char c2;
> int x;
> };
>
>
> struct pad4 {
> char c1;
> char c2;
> int x;
> struct pad1 {
> char c1;
> };
> };
>
> What will be the sizeof for the structs above? (for 32-bit and 64-bit
> machines).
sizeof(struct pad1), sizeof(struct pad2), sizeof(struct pad3),
and nothing (doesn't compile), respectively. We can also infer that
sizeof(struct pad1) >= 1
sizeof(struct pad2) >= 2
sizeof(struct pad3) >= 3
.... but that's all the C language itself can give us.
--
Eric Sosman
lid