/* * ===================================================================================== * * bytes_order.c * * Description: 判断大端格式和小端格式,大端格式是最大字节地址存储数字最低有效字节,小端格式相反 * * ===================================================================================== */ #include<stdio.h> void bytes_order(void) { int a = 0x04030201; char *dp; dp=(char *)&a; if(dp[0]==0x04) { printf("\r\nBig-endian. \r\n"); return; } else if(dp[0]==0x01) { printf("\r\nLittle-endian. \r\n"); return ; } printf("error \r\n"); return ; } int main(void) { bytes_order(); return 0; }
字节大小端判断
最新推荐文章于 2022-08-21 18:53:59 发布