查看当前系统的字节序
#include <stdio.h> #include <stdlib.h> int isLittleEndian() { unsigned short i=1; return (1 == *((char *)&i)); } int main() { if(isLittleEndian()) { printf("低字节序\n"); } else { printf("高字节序\n"); } }
#include <stdio.h> #include <stdlib.h> int isLittleEndian() { unsigned short i=1; return (1 == *((char *)&i)); } int main() { if(isLittleEndian()) { printf("低字节序\n"); } else { printf("高字节序\n"); } }