Created
August 31, 2012 03:55
-
-
Save mbohun/3548910 to your computer and use it in GitHub Desktop.
uint LE/BE conversion via a value called valerie :-)
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> | |
#include <stdint.h> | |
int main(int argc, char* argv[]) { | |
union { | |
uint8_t bytes[4]; | |
uint32_t valerie; | |
} ub_conversion; | |
ub_conversion.valerie = 0xaabbccdd; | |
printf("0x%.2x 0x%.2x 0x%.2x 0x%.2x\n", | |
ub_conversion.bytes[0], | |
ub_conversion.bytes[1], | |
ub_conversion.bytes[2], | |
ub_conversion.bytes[3]); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment