Created
August 30, 2023 09:25
-
-
Save fischerbach/a9b9ec915ac2e347175ad9330d3c8a7f to your computer and use it in GitHub Desktop.
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> | |
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