strrchr(3)
π strrchr(3) β string rear-search character π
okay bestie, come sit with me, we're gonna talk about strrchr from the Linux man-pages (that's the manual name right there in the corner, strrchr(3) β section 3, library functions, iykyk) π
β¨ LIBRARY β¨
Standard C library (libc, -lc) π
so like, yes, it lives in libc, and yes you link it with -lc β the usual. nothing dramatic, she's just a normal library girlie.
πΈ SYNOPSIS πΈ
#include <string.h>
char *strrchr(const char *s, int c);
look at her. so small. so powerful. two arguments and she's done. π¦
π« DESCRIPTION π«
So strrchr() returns a pointer to the last occurrence of the character c in the string s. That's it, that's the whole job. She searches from the back, which is honestly main character energy β everyone else goes forward, she goes backwards. π
Like, if strchr() is the friend who shows up first, strrchr() is the friend who shows up last and still gets the aux cord.
And the way that she's literally equivalent to this:
memrchr(s, c, strlen(s) + 1)
no cap. that's the exact equivalence, strlen(s) + 1 and everything (the +1 is for the null terminator bestie, we don't forget her π).
π RETURN VALUE π
See strchr(3).
fr fr, go read that one, it's got the whole return-value breakdown. I'm not gonna make stuff up, that's not the vibe.
π ATTRIBUTES π
For an explanation of the terms used in this section, see attributes(7). β¨
Here's the tea on strrchr():
- Interface:
strrchr() - Attribute: Thread safety
- Value: MT-Safe
so she's MT-Safe β multithread-safe, she can hang with all your threads at once and not start drama. π«Ά (that's not me guessing, that's literally the table, bestie.)
β STANDARDS β
- C11
- POSIX.1-2008
iconic. certified. periodt. π
π°οΈ HISTORY π°οΈ
She's been around forever, lowkey:
- POSIX.1-2001
- C89
- SVr4
- 4.3BSD
like she predates most of us and she's still slaying. the longevity. π₯
π SEE ALSO π
go read strchr(3) first tho, like I said, that's where the return value lore lives. π¦
okay bye ily, this was strrchr(3) from Linux man-pages 6.20, dated 2026-08-10 β read her, use her, respect her, strrchr ate and left no crumbs πβ¨π
π¦ 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