测试系统的大小印第安序
2015-06-05 22:31
246 查看
直接贴代码了:
#include <stdio.h>
typedef unsigned char BYTE;
int main(void) {
unsigned int num, *p;
p=#
num=0;
*(BYTE *)p=0xff;
if(num==0xff){
printf("its little");
}
else{
printf("its big");
}
return 0;
}
一般X86,ARM是小。
an
a pointer to that same int.
its really a pointer to a byte instead".
the value on the RHS is
Result: num is a 4-byte integer.
One byte of that int will be set to
(it could be the high-byte or the low-byte depending on your platform)
So
either end up being
#include <stdio.h>
typedef unsigned char BYTE;
int main(void) {
unsigned int num, *p;
p=#
num=0;
*(BYTE *)p=0xff;
if(num==0xff){
printf("its little");
}
else{
printf("its big");
}
return 0;
}
一般X86,ARM是小。
numis
an
unsigned int
pis
a pointer to that same int.
(BYTE*)pmeans "pretend
its really a pointer to a byte instead".
*(BYTE*)p =means "Go set that byte to be the value on the RHS."
the value on the RHS is
0xFF.
Result: num is a 4-byte integer.
One byte of that int will be set to
0xFF
(it could be the high-byte or the low-byte depending on your platform)
So
numwill
either end up being
0xFF 00 00 00, or possibly
0x00 00 00 FF
相关文章推荐
- [Servlet]深入研究HttpServlet
- Lemon OA第1篇:简单介绍
- Android学习日记(5)
- 链表的逆制
- 字符串常用操作的源码,拷贝、连接、比较、子串匹配
- Canvas基础入门
- Linux常用命令-文件处理命令-链接命令
- [Servlet]深入研究HttpServlet
- 第二次冲刺——第7天
- java程序员应该熟练掌握的技术
- Lemon OA第1篇:简单介绍
- Cool Edit Pro 中把歌曲的原唱声消除掉制作伴奏带
- [D3] 13. Cleaner D3 code with selection.call()
- 谷歌浏览器打不开
- JavaWeb系列之七(response域与request)
- android file explorer
- java线程学习(二)—并发编程实践学习笔记
- 中科院开源协会镜像站 Android SDK镜像
- 《EventBus使用详解(二)——EventBus使用进阶》
- UITableViewCell重用和性能优化