您的位置:首页 > 其它

CPU大小端的判断

2016-01-15 09:16 155 查看
#include <stdio.h>
#include <stdlib.h>
//X86 and MCU is little endian.
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int checkType()
{
unsigned int value = 0x1122;
unsigned short int temp = (unsigned short int)value;
return temp==0x22?1:0;
}
int main(int argc, char *argv[])
{
if(checkType())
printf("this computer is big endian\n");
else
printf("this computer is little endian\n");
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: