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