Skip to content

Instantly share code, notes, and snippets.

@fischerbach
Created August 30, 2023 09:25
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 fischerbach/a9b9ec915ac2e347175ad9330d3c8a7f to your computer and use it in GitHub Desktop.
Save fischerbach/a9b9ec915ac2e347175ad9330d3c8a7f to your computer and use it in GitHub Desktop.
#include <stdio.h>
union Data {
int integer;
float real;
char character;
};
int main() {
union Data data;
data.integer = 42;
printf("Integer: %d\n", data.integer);
data.real = 3.14;
printf("Real: %f\n", data.real);
data.character = 'A';
printf("Character: %c\n", data.character);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment