机器大小端测试

#include <stdio.h>

int checkEndian(void)
{
    union
    {
        int a;
        char b;
    } c;
    c.a = 1;
    return (c.b == 1);
}

int main(void)
{
    printf("my machine is %s endian\n", checkEndian() ? "little" : "big");
    return 0;
}

 
 

你可能感兴趣的:(大小端)