Skip to content

Instantly share code, notes, and snippets.

@terrencehan
Created November 10, 2012 09:28
Show Gist options
  • Save terrencehan/4050553 to your computer and use it in GitHub Desktop.
Save terrencehan/4050553 to your computer and use it in GitHub Desktop.
check if the machine is big-end or small-end
#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