Skip to content

Instantly share code, notes, and snippets.

@sham1
Created December 16, 2017 07:45
Show Gist options
  • Save sham1/278b40030299f41c2331de63e254e7dd to your computer and use it in GitHub Desktop.
Save sham1/278b40030299f41c2331de63e254e7dd to your computer and use it in GitHub Desktop.
#include <inttypes.h>
#include <stdio.h>
void main(void)
{
uint16_t low_short = (union{uint16_t shorts[2];uint32_t i;})
{.i = 0xDEADBEEF}.shorts[0];
printf("0x%"PRIX16"\n", low_short);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment