wiki

Help! I'm trapped in a wiki!

Site Tools


lang:structs

Structs

Custom data types in C

typedef struct {
	char name[64];
	uint8_t grade;
} Student_t;

Pointers to structs

The arrow operator (→) is used to access fields in a pointer to a struct.
For example: thinkpad->price = 800; (thinkpad is a pointer to a struct laptop_t thinkpad struct)
This is useful instead of writing it as (*thinkpad).price = 800;
read: set the value pointed to by thinkpad, field price to 800

Memory alignment

See https://tomscheers.github.io/2025/07/29/writing-memory-efficient-structs-post.html for first steps to writing memory efficient structs.

lang/structs.txt · Last modified: by 127.0.0.1