strchr(3)
๐ strchr(3) โ string search character ๐
okay bestie, welcome to the strchr page from the Library Functions Manual โจ it's giving "find the first matching letter and go feral" energy and honestly? we're obsessed. let's get into it ๐
๐ธ NAME ๐ธ
strchr โ string search character ๐
no cap, that's literally it. we're hunting a character inside a string.
๐ LIBRARY ๐
Standard C library โ link with -lc ๐ซถ
โจ SYNOPSIS โจ
#include <string.h>
char *strchr(const char *s, int c);
like always, pull in <string.h> first or the compiler will simply not know her ๐
๐ซ DESCRIPTION ๐ซ
so strchr() hands you back a pointer to the first occurrence of the character c inside the string s. first one only. she does not care about the rest ๐
and get this, she's equivalent to both of these expressions (yes, both, iconic behavior):
memchr(s, c, strlen(s) + 1)
strpbrk(s, (char [2]){c, '\0'})
main character energy fr fr ๐
๐ RETURN VALUE ๐
strchr() returns a pointer to the matched character โ or NULL if that character is nowhere to be found ๐ญ like, not in the string at all.
BUT here's the tea ๐: the terminating null byte is considered part of the string. so if you pass c as '\0', strchr() happily returns a pointer to the terminator itself. she is in there. she counts. periodt ๐
๐ฆ ATTRIBUTES ๐ฆ
for the whole explanation of what these terms even mean, go peek at attributes(7) โ she explains it better than I can ngl ๐
- Interface โ
strchr() - Attribute โ Thread safety
- Value โ MT-Safe ๐ฅ
translation: safe to call from multiple threads at once, no drama, no chaos, no vibe check failures โจ
โญ STANDARDS โญ
- C11
- POSIX.1-2008
certified, standards-approved, no notes ๐
๐ HISTORY ๐
she's been around. like, around around:
- POSIX.1-2001
- C89
- SVr4
- 4.3BSD
a true legacy icon, we stan a consistently reliable function ๐
๐ SEE ALSO ๐
the whole girl group, if you wanna meet the rest of the fam:
memchr(3)string(3)strchrnul(3)strnul(3)strpbrk(3)strrchr(3)strsep(3)strspn(3)strstr(3)wcschr(3)
that's the whole page bestie, go forth and find your characters ๐ง๐
this has been Linux man-pages 6.20, dated 2026-08-10, signing off โ stay slaying, stay MT-Safe, and always null-terminate ur strings ๐ซถโจ
๐ฆ 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
- Copyright 1993, David Metcalfe <david@prism.demon.co.uk>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms