方法一: #include <stdio.h> int check_sys() { int i = 1; int *p = &i; char *q = (char *)p; if (*q == 1) { return 0; } else { return 1; } } int main() { int ret = check_sys(); if (ret == 1) { printf("big\n"); } else { printf("little\n"); } return 0; } //方法二: #include <stdio.h> check_sys() { union UN { char c; int i; }un; un.i = 1; if (un.c == 1) { return 0; } else { return 1; } } int main() { int ret = check_sys(); if (ret == 1) { printf("big\n"); } else { printf("little\n"); } return 0; }
原文:http://10706198.blog.51cto.com/10696198/1709359