大小端问题
来源:互联网 发布:北京奥运会圣火 知乎 编辑:程序博客网 时间:2024/05/02 02:47
小端字节序
数据 (由小到大) 地址(由低到高)
0x0029f458 0x78
0x0029f459 0x56
0x0029f45a 0x34
0x0029f45b 0x12
大端字节序
数据(由小到大) 地址(由高到低)
0x0029f458 0x12
0x0029f459 0x34
0x0029f45a 0x56
0x0029f45b 0x79
程序判读大小字节序
#include <stdio.h>
typedef union{
unsigned short value;
unsigned char bytes[2];
}Test;
int main(void)
{
Test test_value;
test_value.value = 0x1234;
if(test_value.bytes[0] == 0x12 && test_value.bytes[1] == 0x34)
printf("big ending");
else if(test_value.bytes[0] == 0x34 && test_value.bytes[1] == 0x12)
printf("little ending");
else
printf("use test_value error");
return 0;
}
{
union{short value; char union_bytes[sizeof(short)] } test;
test.value = 0x0102;
- 存储大小端问题
- 大小端存储问题
- 大小端问题
- cpu大小端问题
- 大小端问题
- 大小端问题
- 大小端问题
- 大小端存储问题
- 大小端问题
- 大小端问题
- 大小端问题
- 大小端问题
- 大小端判断问题
- 存储大小端问题
- 大小端问题
- 大小端问题
- 大小端问题
- 小记:大小端问题!
- 3.22
- insert...on duplicate key update
- Android 你应该知道的学习资源 进阶之路贵在坚持
- 柔性数组
- 关于Activity的启动模式
- 大小端问题
- 用单链表自定义队列
- sublime text 2当中如何设置中文输入支持[ubutu 14.04系统]
- MOOC《Linux内核分析》——创建一个新进程的过程
- HDOJ 一个人的旅行 2066【简单最短路】
- 对于请求的URL中有特殊字符的处理
- 编写一个程序从标准输入读取字符,并把他们写到标准输出。除了大写字母转换成小写字母之外,其他的原样输出。
- printf("%*s);
- 在Ubuntu中怎样使用校园网上网,以及安装mentohust教程