Structures for C Programmings
Structures group related values under one type, while unions let several members share the same memory. Together with pointers they let you build data structures in C, such as linked lists, stacks, queues and trees, since the language has no built-in collections beyond arrays.
Stage: Memory · Part of the C Programming roadmap · Last reviewed 19 November 2026
What to learn in Structures
- Define a struct, create instances and access members with dot and arrow
- Use typedef to give a struct a short type name
- Build a singly linked list with insert, search and delete operations
- Explain struct padding and use sizeof to inspect it
- Describe when a union is useful and the risk of reading the wrong member
Structures interview questions
Why can sizeof a struct be larger than the sum of its members?
The compiler inserts padding so each member sits at an address aligned to its type, which the hardware handles efficiently. Ordering members from largest to smallest alignment can reduce padding, though layout rules depend on the platform.
How do you free a linked list correctly?
Walk the list, saving the next pointer before calling free on the current node, then advance using the saved pointer. Freeing first and reading next afterwards uses freed memory. Finally set the head to NULL.
Where Structures fits in the C Programming roadmap
Structures belongs to the Memory stage (intermediate level), which takes about 30 hours. Pointers and the heap.
Other units in this stage
Back to the full C Programming roadmap