structs
typedef struct {
const char *host;
int port;
} Target;
Target t = {"local", 443};
C23 allows empty initialization = {}
Use it when zero is the intended default
Tags and typedef
A tag names the type in struct namespace A typedef creates an alias Both appear in real code, pick one style and keep it consistent
Passing
Passing a struct by value copies it
Passing a pointer avoids the copy and lets the function modify it
Use const Target * when modification is not intended
Layout
Padding exists Field order affects size Do not assume a struct maps byte for byte onto a network packet or file format
Next
Memory in 09 memory
Posted