host-order.c

来自「嵌入式linux下」· C语言 代码 · 共 17 行

C
17
字号
/*Little Application to test processor's endian mode*/#include <stdio.h>int main(){	unsigned int a[1];	a[0] = 0x3344;	unsigned char *b = a;	unsigned char *c = (b+0x00000001);	printf("a:0x%x,b:0x%x,c:0x%x,a[0]:0x%x,*b:0x%0x,*c:0x%x\n",a,b,c,a[0],*b,*c);	if(*b == 0x33)  	printf("the host(processor) byte order is big-endian!\n");	if(*b == 0x44)  	printf("the host(processor) byte order is little-endian!\n");	printf("unsigned int:%d\n",sizeof(unsigned int));	return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?