#include <stdio.h> int checkCPU() { union w { int a; char b; }c; c.a = 1; printf("c.a的值: %x\n",c.a); printf("c.b的值: %x\n",c.b); return ( c.b == 1 ); } int main () { //JSRUN引擎2.0,支持多达30种语言在线运行,全仿真在线交互输入输出。 if(checkCPU()) printf("这CPU是小端"); else printf("这CPU是大端"); return 0; }