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