Skip to content

Instantly share code, notes, and snippets.

@mbs0221
Last active July 11, 2023 15:48
Show Gist options
  • Select an option

  • Save mbs0221/2f4418ac92fae8a198b0c03e1a2b35ca to your computer and use it in GitHub Desktop.

Select an option

Save mbs0221/2f4418ac92fae8a198b0c03e1a2b35ca to your computer and use it in GitHub Desktop.
endian.c
#include <stdio.h>
int main(int argc, char *argv[])
{
union w {
int a;
char b;
} c;
c.a = 1;
printf("This cpu is %s\n", c.b == 1 ? "little-endian" : "big-endian");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment