Scroll to navigation

countof(3) Library Functions Manual countof(3)

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)

2025-08-19 Linux man-pages (unreleased)