Skip to content

Instantly share code, notes, and snippets.

@Xevion
Created July 6, 2022 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xevion/332bab8203130d4278ff9f306a5b018c to your computer and use it in GitHub Desktop.
Save Xevion/332bab8203130d4278ff9f306a5b018c to your computer and use it in GitHub Desktop.
// Hello world! Cplayground is an online sandbox that makes it easy to try out
// code.
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
union magic {
uint8_t buf[4];
uint32_t magic2;
};
int main() {
union magic test;
test.buf[0] = 0x11;
test.buf[1] = 0x22;
test.buf[2] = 0x33;
test.buf[3] = 0x44;
// 44332211
printf("%x", test.magic2);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment