strchrnul(3)
π NAME π
okay so bestie, this is strchrnul β it does a string search for a character or a NUL, no cap β¨
π LIBRARY π
Standard C library (that's libc, link it with -lc) π«Ά
β¨ SYNOPSIS β¨
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <string.h>
char *strchrnul(const char *s, int c);
heads up babe, you literally need that _GNU_SOURCE define β it's not optional, she's required π
πΈ DESCRIPTION πΈ
so strchrnul() is giving strchr(3) energy, right, EXCEPT β plot twist β if c is not found in s, she doesn't return NULL. Nope. She returns a pointer to the null byte at the end of s. iconic behaviour honestly π
She's equivalent to both of these expressions, like pick your fave:
strchr(s, c) ?: strnul(s)
s + strcspn(s, (char [2]){c, '\0'})
π RETURN VALUE π
she returns a pointer to the matched character, OR β if the character isn't found β a pointer to the null byte at the end of s. that's it, that's the whole vibe π¦
π ATTRIBUTES π
for the whole explanation of what these terms even mean, go peek at attributes(7) bestie:
strchrnul()β Thread safety: MT-Safe π₯
π STANDARDS π
GNU. periodt.
π°οΈ HISTORY π°οΈ
she's been around: glibc 2.1.1, FreeBSD 10, NetBSD 8. a true veteran π
π SEE ALSO π
string(3), strchr(3), strnul(3), strcspn(3), strspn(3)
okay that's the whole page, bestie, you're so welcome π this was Linux man-pages 6.20, dated 2026-02-25, and yes she ate, no crumbs left πβ¨π¦
π¦ 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