通过整型数组中间值的指针强制转换成字符指针来实现:
int IPTest[3] = {0,513,0}; char * CPTest = (char *)&(IPTest[1]); CPTest += 1; if (2 == *CPTest) { printf("Little endian\n"); } else { printf("big endian\n"); }