C++如何判断大小端
http://bbs.chinaunix.net/thread-1257205-1-1.html
#include <stdio.h> #include <string.h> #include <stdlib.h> int main(void) { unsigned short v = 0x0102; unsigned char *p = (unsigned char *)&v; if (*p == 0x01) printf("big\n"); else if (*p == 0x02) printf("small\n"); return 0; } |