countof(3)

πŸ“¦
version 6.20 Β· 4 versions
, in arch rolling, nixpkgs unstable

✨ 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 16
  • clang 21
  • gnulib 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