Skip to content

Instantly share code, notes, and snippets.

@nanki
Created May 7, 2012 04:41
Show Gist options
  • Save nanki/2625961 to your computer and use it in GitHub Desktop.
Save nanki/2625961 to your computer and use it in GitHub Desktop.
#include <stdio.h>
typedef union {
double d;
int i;
} union_t;
void dump_union(union_t u) {
unsigned char *c = (unsigned char *)&u;
int i;
for (i = 0; i < sizeof(union_t); i++) {
printf("%02x ", c[i]);
}
printf("\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment