2
我定義一個結構和如下的聯合:如何找到一個結構元件作爲聯合字節數組的索引的索引(在標準C)
struct MY_STRUCT
{
int a;
unsigned int x;
char c;
};
union MY_UNION
{
unsigned char myByte[sizeof(struct MY_STRUCT)];
struct MY_STRUCT myStruct;
};
我怎樣找到位置中的myStruct.x
(指數) myByte[]
數組動態?
使用'offsetof'。 – BLUEPIXY