| 1 |
.\" Copyright, the authors of the Linux man-pages project |
| 2 |
.\" |
| 3 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 4 |
.\" |
| 5 |
.TH countof 3 2026-02-10 "Linux man-pages 6.18" |
| 6 |
.SH NAME |
| 7 |
countof, _Countof \- count the number of elements in an array |
| 8 |
.SH LIBRARY |
| 9 |
Standard C library |
| 10 |
.RI ( libc ) |
| 11 |
.SH SYNOPSIS |
| 12 |
.nf |
| 13 |
.B #include <stdcountof.h> |
| 14 |
.P |
| 15 |
.BI "size_t countof(" array ); |
| 16 |
.fi |
| 17 |
.SH DESCRIPTION |
| 18 |
This operator counts the number of elements in an array. |
| 19 |
.P |
| 20 |
If the operand is not an array, |
| 21 |
it produces a compilation error. |
| 22 |
.P |
| 23 |
There's a keyword, |
| 24 |
.BR \%_Countof (), |
| 25 |
that behaves identically, |
| 26 |
and can be used without including |
| 27 |
.IR <stdcountof.h> . |
| 28 |
.SH RETURN VALUE |
| 29 |
The number of elements in the array. |
| 30 |
.SH STANDARDS |
| 31 |
C2y. |
| 32 |
.SH HISTORY |
| 33 |
gcc 16, clang 21, gnulib 202507. |
| 34 |
.SH SEE ALSO |
| 35 |
.BR operator (7) |