Created
July 20, 2014 15:25
-
-
Save rainyear/19d9c938c98039677f9b to your computer and use it in GitHub Desktop.
Show bytes and check which endian the machine is.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
typedef unsigned char* byte_ptr; | |
void show_bytes(byte_ptr start, int len){ | |
for(int i = 0; i < len; i++) | |
printf("\t%.2x", start[i]); | |
printf("\n"); | |
} | |
int main(){ | |
int i = 0x1234567; | |
show_bytes((byte_ptr) &i, sizeof(i)); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment