/* * is-little-endian.c */ #include #include #include #include #include typedef unsigned char* byte_pointer; int is_little_endian() { int test_num = 0xff; byte_pointer byte_start = (byte_pointer) &test_num; if (byte_start[0] == 0xff) { return 1; } return 0; } int main(int argc, char *argv[]) { uint64_t x; if (argc != 2) { fprintf(stderr, "Usage: %s \n", argv[0]); exit(EXIT_FAILURE); } x = strtoul(argv[1], NULL, 0); printf("0x%" PRIx64 " ==> 0x%" PRIx64 "\n", x, bswap_64(x)); exit(EXIT_SUCCESS); }