strnchr(9)
π strnchr(9) β the Kernel API Manual page you didn't know you needed
okay bestie, so this is the Kernel API Manual page for strnchr, and it's literally the little function that finds a character inside a string but only looks at the first count characters. no cap, it's giving "search but make it bounded" and honestly? we stan a cautious queen. π
β¨ SYNOPSIS β¨
char * strnchr (const char *s , size_t count , int c );
like, that's the whole vibe right there. three arguments, one pointer returned. slay. π
π¦ ARGUMENTS π¦
sβ the string you're searching through. bestie, this is your haystack. πcountβ how many characters you're actually allowed to look at. not one more, not one less. respect the boundary. βcβ the character you're looking for. the one. the main character of this search. π
πΈ DESCRIPTION πΈ
so here's the tea: the NUL-terminator is considered part of the string, and you can absolutely search for it. like, it's not off-limits. it's invited to the party too. π so if you're looking for '\0', go off β strnchr will find it and won't even side-eye you for it. π«Ά
fr fr, don't forget that detail. the NUL terminator is valid search bait. iykyk. π
π§ SEE ALSO π§
- Kernel file
./lib/string.c strncasecmp(9)stpcpy(9)strcmp(9)strncmp(9)strchr(9)strchrnul(9)strnchrnul(9)strrchr(9)strspn(9)strcspn(9)strpbrk(9)strsep(9)memset(9)memset16(9)memset32(9)memset64(9)memcpy(9)memmove(9)memcmp(9)bcmp(9)memscan(9)strstr(9)strnstr(9)memchr(9)memchr_inv(9)
like, that's the whole friend group right there. the string-and-memory function squad. iconic. π
sign-off bestie style: this little gem lives in ./lib, and it's stamped October 2026 β so yeah, it's current, it's cute, and it's strnchr(9). periodt. ππ¦β¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms