Skip to content

Instantly share code, notes, and snippets.

@clarkzjw
Created March 28, 2015 02:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clarkzjw/797e213941a7fdda33ab to your computer and use it in GitHub Desktop.
Save clarkzjw/797e213941a7fdda33ab to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main()
{
char *str = "HelloWorld";
int a = *(int *)str;
if (a == 0x6c6c6548)
printf("Little endian\n");
else if (a == 0x48656c6c)
printf("Big endian\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment