Created
August 31, 2015 03:54
-
-
Save ls0f/b3cd23e5f87f52373cf5 to your computer and use it in GitHub Desktop.
查看机器是大端还是小段
This file contains 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
#include<stdio.h> | |
typedef unsigned char * byte_pointer; | |
int showBigOrLittleEnd() | |
{ | |
int i = 0x01; | |
byte_pointer bp = (byte_pointer) &i; | |
if (bp[0] == 0x01) | |
return 1; | |
else | |
return 0; | |
} | |
void main() | |
{ | |
if (showBigOrLittleEnd() == 1) | |
printf("little end\n"); | |
else | |
printf("big end\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment