Index

My C is rusty. Here are a few tricks I forgot and had to rediscover:

int array[42];
int *pointer = array + 8;

// This will be 8, not 8 * sizeof int
size_t x = pointer - array;

Number of elements in an array:

int array[42];

// x == 42 * sizeof int. Not what we want
size_t x = sizeof array;

// The right way to do it: y == 42
size_t y = sizeof array / sizeof array[0];

That is all.