Skip to content

Instantly share code, notes, and snippets.

@shriroopjoshi
Created July 23, 2019 18:45
Show Gist options
  • Save shriroopjoshi/c41ff784d073508f618e389e7d427bfe to your computer and use it in GitHub Desktop.
Save shriroopjoshi/c41ff784d073508f618e389e7d427bfe to your computer and use it in GitHub Desktop.
Code to check endian-ness of the system
#include <stdio.h>
int main() {
unsigned int i = 1;
char *c = (char*) &i;
if (*c)
printf("Little endian\n");
else
printf("Big endian\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment