Created
January 11, 2018 12:17
-
-
Save itang/0da3ccb6d4be0dbff182151a3a14f22d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| typedef enum { false, | |
| true } bool; | |
| bool IsBigEndian() | |
| { | |
| int a = 0x1234; | |
| char b = *(char *)&a; //通过将int强制类型转换成char单字节,通过判断起始存储位置。即等于 取b等于a的低地址部分 | |
| if (b == 0x12) | |
| { | |
| return true; | |
| } | |
| return false; | |
| } | |
| int main(int argc, char **argv) | |
| { | |
| printf("%d\n", IsBigEndian()); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment