fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. unsigned int x = 0x12345678;
  5. unsigned char *byte = (unsigned char *)&x;
  6.  
  7. if (byte[0] == 0x78) {
  8. printf("Little Endian\n");
  9. } else if (byte[0] == 0x12) {
  10. printf("Big Endian\n");
  11. }
  12.  
  13. return 0;
  14. }
Success #stdin #stdout 0.01s 5284KB
stdin
123
stdout
Little Endian