L
luke
hi,
in Visula C++ 6.0 I have declared a struct like this:
typedef struct _WRITE_INPUT {
ULONG DeviceNumber;
ULONG RegisterNumber;
union {
USHORT ShortData;
UCHAR CharData;
};
} WRITE_INPUT;
I can't understand why, sizeof(WRITE_INPUT) returns 12. It should
return 10, shouldn't it?
sizeof(ULONG) = 4
sizeof(ULONG) = 4
sizeof(USHORT) = 2 (longest union field)
4 + 4 + 2 = 10
thanks
bye
luke
in Visula C++ 6.0 I have declared a struct like this:
typedef struct _WRITE_INPUT {
ULONG DeviceNumber;
ULONG RegisterNumber;
union {
USHORT ShortData;
UCHAR CharData;
};
} WRITE_INPUT;
I can't understand why, sizeof(WRITE_INPUT) returns 12. It should
return 10, shouldn't it?
sizeof(ULONG) = 4
sizeof(ULONG) = 4
sizeof(USHORT) = 2 (longest union field)
4 + 4 + 2 = 10
thanks
bye
luke