查看機器大端法仍是小端法的源代碼

#include <stdio.h>

int main(int argc, char *argv[])
{
	unsigned short u16 = 0x1234;
	unsigned char *p_u16 = (unsigned char *)&u16;

	if(p_u16[0] == 0x34 && p_u16[1] == 0x12)
		printf("little endian!\n");
	if(p_u16[0] == 0x12 && p_u16[1] == 0x34)
		printf("big endian!\n");
	
	return 0;
}
相關文章
相關標籤/搜索