Loading…
Loading…
Topic
Articles and problems tagged Structures.
Seven exercises with full, runnable solutions: a stack as a circular linked list, a circular doubly linked list, preorder and postorder traversal without recursion, copying and comparing binary search trees with recursion, and inserting a node as a left child in a threaded binary tree.
Five exercises with full solutions: a recursive determinant using calloc, reading and changing file attributes in a raw directory entry, a sorted directory listing with a linked list, and decoding a boot sector and partition table byte by byte.
Five exercises on structures and pointers: arrays of pointers to structures, a list of malloc'd nodes, 2-D char arrays in a structure, nested structures through a pointer, and calling a function before declaring it. Predict each output, then find the hidden bug.
Harder puzzles on structures that point to structures: ++ and -- inside ->, arrays of pointers to structures, swapping through structure pointers, malloc'd nodes, a two-node doubly linked list, and a circular list that never ends. Predict each output, then follow the step-by-step explanation.
Worked puzzles on structures: the dot versus arrow rule, the addresses and padding of structure members, arrays of structures, structures holding char arrays and char pointers, nested structures, and arrays of structures that point to each other. Predict each output, then read the explanation.
Point at a structure, reach its members with ->, pass structures by address, walk arrays of structures with pointers and create structures with malloc. Then see how member offsets work, and how offsetof finds a whole structure from a pointer to one member.
Real-world data rarely comes as a single int or float. Learn how a C structure groups dissimilar data into one unit: declaring structures, the dot operator, how members sit in memory (including padding), arrays of structures, nesting, copying and passing structures to functions.