A C tip about enums By Edward Willis (gopher://encw.xyz and http://encw.xyz) Published Jul/12/2024 Here is a C tip: If you need to store how many items there are in an enumeration, just add an extra one on the end. enum ANIMAL { ANIMAL_DOG, ANIMAL_CAT, ANIMAL_BIRD, ANIMAL_NUM }; I figure most know this, but hey, maybe it helps someone. I find it particularly useful for random selection, e.g.: r = rand() % ANIMAL_NUM;