C检测大小端模式

int
12345678
00001100001000100011100001001110
大端char小端char
#include<stdio.h>
#include<stdlib.h>
int main()
{
	union TestUnion
	{
		int a;
		char b;
	}tu;
	tu.a= 0x12345678;
	printf("%s\nb=0x%X\t a=0x%X\n",tu.b==0x12?"大端模式":"小端模式",tu.b,tu.a);
	system("pause");
	return 0;
}

posted on 2022-09-18 17:46  星云*  阅读(44)  评论(0编辑  收藏  举报