How to check endianness Posted on 2020-05-18 Edited on 2021-01-25 In C++ , Computer architecture Disqus: Symbols count in article: 279 Reading time ≈ 1 mins. big-endian: 低地址 -> 高地址 0x12345678 高位字节 -> 低位字节 更具有可读性 Java一律是big-endian,与平台无关 little-endian: 高地址 -> 低地址 0x12345678 高位字节 -> 低位字节 x86是little-endian 1234int a = 0x12345678;char *p = (char *)&a;if (*p == 0x78) cout << "little" << endl;else cout << "big" << endl;