Created
November 10, 2012 09:28
-
-
Save terrencehan/4050553 to your computer and use it in GitHub Desktop.
check if the machine is big-end or small-end
This file contains 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 <stdlib.h> | |
#include <stdio.h> | |
void | |
print_in_byte(void *a, int size){ | |
char *byte_ptr = (char *) a; | |
while (size--) { | |
printf("%.2x ", *byte_ptr++); | |
} | |
printf("\n"); | |
return (void) 0; | |
} | |
int | |
main(int argc, char *argv[]){ | |
int a = 0x0a0b0c0d; | |
print_in_byte(&a, sizeof(a)); | |
return EXIT_SUCCESS; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment