Manpage logo

countof - count the number of elements in an array

NAME  LIBRARY  SYNOPSIS  DESCRIPTION  RETURN VALUE  STANDARDS  HISTORY  SEE ALSO 

NAME

countof, _Countof − count the number of elements in an array

LIBRARY

Standard C library (libc)

SYNOPSIS

#include <stdcountof.h>

size_t countof(array);

DESCRIPTION

This operator counts the number of elements in an array.

If the operand is not an array, it produces a compilation error.

There’s a keyword, _Countof(), that behaves identically, and can be used without including <stdcountof.h>.

RETURN VALUE

The number of elements in the array.

STANDARDS

C2y.

HISTORY

gcc 16, clang 21.

SEE ALSO

operator(7)


Updated 2026-06-01 - jenkler.se | uex.se