Skip to content

Structs and typedef: . vs ->

Handout

Grouping related data

  • A struct groups several values into one thing. A point has an x and a y; a rectangle has a width and a height.
  • Each value inside is called a member (or field). They can have different types.
  • Structs let you pass one tidy thing around instead of many loose variables.

A Point struct with x and y; reach a field with . on the struct, or -> through a pointer

Handout

Log in or create account

IGCSE & A-Level