diff --git a/day4/union_test.c b/day4/union_test.c new file mode 100644 index 0000000..90f13e0 --- /dev/null +++ b/day4/union_test.c @@ -0,0 +1,23 @@ +#include +#include + +union Data{ + int i; + float f; + char str[20]; +}; + +int main(){ + union Data data; + + data.i = 10; + printf("data.i: %d\n", data.i); + + data.f = 3.14; + printf("data.f: %f\n", data.f); + + strcpy(data.str, "Hello"); + printf("data.str: %s\n", data.str); + + return 0; +}