Step Into C · Lesson 18 · Systems C
Binary Data & Layouts
Exact-width integers, packed structs, offsetof and parsing byte buffers.
- ~35 minreading and coding
- 4missions
- membersaccess
- Clanguage
Part of Step Into C. The full lesson, its missions and the real compiler and debugger are in the course. Try a free lesson first to see how it works.
Network packets, file headers and OS structures are defined byte for byte. int and long vary across platforms, so for this kind of work you use the exact-width types from <stdint.h>:
In this lesson
- When the size must be exact
- Reading multi-byte values from raw bytes
- Packed structs
- offsetof
- Parsing a buffer into a struct
- Pointers as numbers
Missions
- Exact widths
- Little-endian reader
- Pack it tight
- Parse a header