Last active
February 20, 2021 19:01
-
-
Save FreedomBen/38b05f1ad113406ea2c87c02c402d3cb to your computer and use it in GitHub Desktop.
Bash script to generate and compile a C program to check Endianness of your system. Cleans up after it is done
This file contains 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
cat << EOF > check-endianness.c | |
#include <stdio.h> | |
int main() { | |
int n = 1; | |
// little endian if true | |
if(*(char *)&n == 1) { | |
printf("Little endian\n"); | |
} else { | |
printf("Big endian\n"); | |
} | |
} | |
EOF | |
gcc -o check-endianness check-endianness.c && ./check-endianness && rm check-endianness check-endianness.c |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment