Step Into Labs

Step Into C · Lesson 18 · Systems C

Binary Data & Layouts

Exact-width integers, packed structs, offsetof and parsing byte buffers.

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

Missions

  1. Exact widths
  2. Little-endian reader
  3. Pack it tight
  4. Parse a header