Structures, Unions & Pointers in C: quick revision, 15 bites
All 15 revision bites from this kit, free and with no sign-up.
Struct vs Union: One Memory Rule Changes Everything
Same syntax, totally different memory.
A **struct** gives every member its own memory; a **union** makes all members share one block sized to the largest member.
Takeaway. Struct = separate boxes; union = one box shared by many labels.
Structure: A Named Bundle of Mixed Types
One name, many data types.
Takeaway. A struct is a blueprint; each variable of that type gets its own copy of all members.
Union: One Memory Block, Many Faces
All members, one address.
Takeaway. A union saves memory but only one member holds a valid value at any moment.
Pointer: A Variable That Holds an Address
Pointers don't store data — they store where.
Takeaway. & gives an address; * follows it to the value.
Accessing Struct Members: Dot vs Arrow
Dot for values, arrow for pointers.
Takeaway. Arrow operator = dereference + member access in one step.
Union in Action: Only One Value Survives
Write one member, lose the others.
Writing `d.f` overwrote the bytes that `d.i` was using — so reading `d.i` gives meaningless data.
Takeaway. Never read a union member other than the one last written.
Reading the Wrong Union Member
This bug is silent and deadly.
Takeaway. Unions demand discipline: know which member is live.
Forgetting to Initialize a Pointer
Wild pointers crash programs.
Takeaway. An uninitialized pointer points to nowhere safe.
When to Choose Struct vs Union
Pick by memory, not by habit.
Takeaway. Struct for records, union for memory-efficient variants.
sizeof Tells the Truth About Memory
One operator reveals the layout.
Takeaway. Use `sizeof` to verify memory usage — never assume.
Passing a Struct to a Function via Pointer
Pointers avoid copying big structs.
Takeaway. Passing by pointer is faster and lets the function modify the original.
Where Unions Shine: Embedded Systems
Every byte counts in firmware.
Takeaway. Unions are a memory-saving tool, not a general-purpose container.
Pointers + Structs = Linked Lists
Self-referencing structs build data structures.
A struct containing a pointer to its own type is the foundation of linked lists, trees, and graphs.
Takeaway. Self-referential structs are the building blocks of dynamic data structures.
Exam Favourite: Size of a Union
This question appears every year.
Takeaway. Union size = largest member; struct size = sum + padding.
Remember: Struct = Stack, Union = Share
Two S-words, two rules.
**S**truct = **S**tack of separate boxes. **U**nion = **U**nited (shared) memory. The first letter tells you the memory rule.
Takeaway. Struct stacks members; union unites them in one block.
Your notes can be a kit like these
Every kit here was made from real study material. Point Veda at a chapter, a PDF, a photo or a link and get notes, flashcards, practice MCQs, games and a scored test — free, in 42 languages.
- Chapter notes
- Flashcards
- Practice MCQs
- Scored tests
- Exam prep
Get Veda free See what students get
Free to start · No ads · Works in 42 languages