big little endian 测试


    char a[10] = {0};
    int x = 0x12345678;
    printf("x is:%08x\n",x);
    int *y= (int*)a;
    *y=x;
    printf("a is:%08x\n",*y);
    printf("a bit:%02x",a[3]);
    printf("%02x",a[2]);
    printf("%02x",a[1]);
    printf("%02x",a[0]);
    printf("\n");
    int *z = (int*)(a+2);
    *z=0xFF;
    printf("z is:%08x\n",*y);
timfeng@15:53:58:~/mycode/c-cpp/prime $./a.out 
x is:12345678
a is:12345678
a bit:12345678
z is:00ff5678
timfeng@15:54:08:~/mycode/c-cpp/prime $


Copyright © FengGuangtu 2017