Skip to content

Instantly share code, notes, and snippets.

@LizzyFleckenstein03
Created January 15, 2023 15:32
Show Gist options
  • Save LizzyFleckenstein03/c971a43281a20ee192573a0e7a11b714 to your computer and use it in GitHub Desktop.
Save LizzyFleckenstein03/c971a43281a20ee192573a0e7a11b714 to your computer and use it in GitHub Desktop.
/*
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