Created
January 15, 2023 15:32
-
-
Save LizzyFleckenstein03/c971a43281a20ee192573a0e7a11b714 to your computer and use it in GitHub Desktop.
This file contains 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
/* | |
This program demonstrates how unnamed anonymous struct/union fields get embedded in C. | |
License: CC BY-SA 4.0 | |
*/ | |
typedef struct { | |
int age; | |
struct { | |
char *name; | |
}; | |
union { | |
float a; | |
int b; | |
}; | |
} Player; | |
int main() | |
{ | |
Player p; | |
p.age = 23; | |
p.name = "player"; | |
p.a = 5; | |
p.b = 4.2; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment