概述
参考自《程序员面试攻略》
一般也就想到
bool endianess(){
int testNum=1;
char *ptr=(char *)&testNum;
return (*ptr);
}
作者提出用union的方法好聪明!
bool endianess(){
union{
int theInteger;
char singleByte;
}endianTest;
endianTest.theInteger=1;
return endianTest.singleByte;
return (*ptr);
}
union还可以这样用,膜拜。
其实几乎一般都不用union。
最后
以上就是爱撒娇方盒为你收集整理的大小尾端数据测试的全部内容,希望文章能够帮你解决大小尾端数据测试所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复