記住,書寫方式是大頭。
****************************************************************************
想要查看當前環境是高地址還是低地址可以使用聯合體
如:
union str{
int b;
char a;
};
int main()
{
str s;
s.b = 'a';
cout<<*((char *)(&s.b))<<endl;
}
如果輸出是a,則是小頭,否則是大頭。
********************************************************************************
Linux 操作系統中相關的源代碼是怎麼做的:
static union { char c[4]; unsigned long mylong; } endian_test = {{ 'l', '?', '?', 'b' } };
#define ENDIANNESS ((char)endian_test.mylong)