Created
November 5, 2014 18:46
-
-
Save theonewolf/a457ee36d37e43f74bc5 to your computer and use it in GitHub Desktop.
endian test program
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 <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
int main(int argc, char* argv[]) | |
{ | |
uint32_t int32 = 0x04030201; | |
uint64_t int64 = 0x0807060504030201; | |
uint8_t* p32 = (uint8_t*) &int32; | |
uint8_t* p64 = (uint8_t*) &int64; | |
fprintf(stdout, "p32[0] = 0x%0.2x\n", p32[0]); | |
fprintf(stdout, "p32[1] = 0x%0.2x\n", p32[1]); | |
fprintf(stdout, "p32[2] = 0x%0.2x\n", p32[2]); | |
fprintf(stdout, "p32[3] = 0x%0.2x\n", p32[3]); | |
fprintf(stdout, "p64[0] = 0x%0.2x\n", p64[0]); | |
fprintf(stdout, "p64[1] = 0x%0.2x\n", p64[1]); | |
fprintf(stdout, "p64[2] = 0x%0.2x\n", p64[2]); | |
fprintf(stdout, "p64[3] = 0x%0.2x\n", p64[3]); | |
fprintf(stdout, "p64[4] = 0x%0.2x\n", p64[4]); | |
fprintf(stdout, "p64[5] = 0x%0.2x\n", p64[5]); | |
fprintf(stdout, "p64[6] = 0x%0.2x\n", p64[6]); | |
fprintf(stdout, "p64[7] = 0x%0.2x\n", p64[7]); | |
return EXIT_SUCCESS; | |
} |
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
endian-test: endian-test.c | |
gcc endian-test.c -o endian-test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment