Structs & typedef in C
From the C cheat sheet · Structs, Unions & Enums · verified Jul 2026
Structs & typedef
Composite types and member access.
c
// Quick Reference
struct Point { int x, y; };
struct Point p = {3, 4};
p.x; // dot for a value
ptr->x; // arrow for a pointer💡 Use . to access a struct value's members and -> through a struct pointer.
⚡ typedef struct {...} Name lets you write Name instead of struct Name everywhere.
📌 A union overlaps all members in one memory slot - only one is valid at a time.
🟢 Designated initializers ({.x = 1}) make struct setup clear and order-independent.
structsunionsenums