存储模式分为两种:
大端模式(Big_endian):数据的高字节存储在低地址中,低字节存储在高地址中。
小端模式(Little_endian):数据的高字节存储在高地址中,低字节存储在低地址中。
#include <stdio.h> #include <malloc.h> // 返回1则为小端存储,否则为大端存储 int checkSystem() { union check { int i; char ch; }c; c.i = 1; return (c.ch == 1); } int main() { printf("%d\n", checkSystem()); return 0; }