Created
April 25, 2013 02:52
-
-
Save lingling2012/5457180 to your computer and use it in GitHub Desktop.
check little or big endian.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int checkEndian(void) { | |
union { | |
int i; | |
char ch; | |
}c; | |
c.i = 1; | |
return (c.ch == 1); | |
} | |
int main(int argc, char *argv[]) { | |
int rs; | |
rs = checkEndian(); | |
if (rs == 1) { | |
printf("little endian"); | |
} else { | |
printf("big endian"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment