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
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms