Chinaunix首页 | 论坛 | 博客
  • 博客访问: 544303
  • 博文数量: 252
  • 博客积分: 1068
  • 博客等级: 少尉
  • 技术积分: 1775
  • 用 户 组: 普通用户
  • 注册时间: 2012-05-05 21:33
文章分类

全部博文(252)

文章存档

2013年(21)

2012年(231)

分类:

2012-06-04 14:37:57

原文地址:Little_endian or Big_endian 作者:kevin33643

//Little_endian:CPU对操作数的存储方式是低字节在低地址;(Intelx86)
//Big_endian   :CPU对操作数的存储方式是低字节在高地址;
#include
using namespace std;
 
int CheckCPU()
{
    union w
    {
        int a;
        char b;
    }c;
    c.a=1;
    return (c.b==1);//Little_endian(==1)
}
 
int main()
{
    int temp;
    temp=CheckCPU();
    if(temp)
        cout<<"Little_endian"<    else
        cout<<"Big_endian"<    return 0;
}
阅读(329) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~