countof(3)
β¨ countof(3) β the Library Functions Manual glow-up β¨
okay bestie, gather round, we're in section 3 of the manual and this one is so useful it's basically main character energy π«Ά
πΈ NAME πΈ
countof, _Countof β literally just counts how many elements are in an array π
π LIBRARY π
Standard C library (libc) β she's iconic, she's everywhere, no cap π
β¨ SYNOPSIS β¨
#include <stdcountof.h>
size_t countof(array);
π« DESCRIPTION π«
okay so, this operator counts the number of elements in an array. that's the whole vibe. it's giving "how many of u are there" and the array is like "this many" β¨
BUT β and this is the important part, bestie β if the operand is not an array, it produces a compilation error. not a warning, not a little suggestion, a full on compilation error π. the compiler said "no β€οΈ". so don't try it with a pointer, iykyk.
there's also a keyword, _Countof(), that behaves identically, and can be used without including <stdcountof.h>. same energy, no include needed, she's self-sufficient π
π RETURN VALUE π
The number of elements in the array. that's it. that's the tea π
π STANDARDS π
C2y. periodt.
π¦ HISTORY π¦
she didn't come from nowhere bestie, she's been making moves:
gcc 16clang 21gnulib 202507
π SEE ALSO π
operator(7) β go read it, it's giving lore π
fr fr, remember: arrays only. anything else and the compiler will humble you π
signing off with love from the Linux man-pages 6.20, dated 2026-02-10 πβ¨π
π¦ where this page comes from
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages 6.20
- π the page's license: Linux-man-pages-copyleft
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms