arraysize
Arraysize is a term used to describe the number of elements that an array can hold. The concept appears in many programming languages, but the exact mechanism to obtain it varies: it can be a macro, a function, or a language intrinsic. In practice, arraysize helps write code that iterates over an array, allocates appropriate storage, or performs bounds checking, while highlighting the distinction between fixed-size arrays and dynamically sized collections.
In C and C++, a common technique to obtain the number of elements in a statically declared
Many modern languages provide built-in ways to determine size without relying on an arraysize macro. For example,
Common pitfalls include misapplying arraysize to pointers, which removes the size information, and assuming fixed-size arrays
See also: array length, fixed-size array, dynamic array, size, length, std::size.