判断大小端
int main() { int i = 0x04030201; char *p = (char *)&i; if(*p == 1) printf("littel\n"); else if(*p == 4) printf("big\n"); else printf("???\n"); int a[4] = {1, 2, 3, 4}; char *pa = (char *)a; if(*pa == 1) printf("littel\n"); else if(*pa == 4) printf("big\n"); else printf("???\n"); /* 低地址 <- 0 +1 +2 +3 -> 高地址 littel: a[0] a[1] a[2] a[3] 1 2 3 4 big : a[4] a[3] a[2] a[1] 4 3 2 1 littel: 1 2 3 4 big : 4 3 2 1 */ }