rawmemchr(3)

πŸ’– rawmemchr(3) β€” the Library Functions Manual page, but make it make sense πŸ’–

okay bestie, sit down, hydrate, and let's talk about rawmemchr β€” a lil function from the Library Functions Manual section of your fave man pages. she's from the Standard C library (libc, -lc) and she is, and I say this with love, a menace. 🫢


✨ NAME ✨

rawmemchr β€” memory raw search character πŸ”


πŸ“š LIBRARY πŸ“š

Standard C library (libc, -lc) πŸ’…


🌸 SYNOPSIS 🌸

#define _GNU_SOURCE  /* See feature_test_macros(7) */
#include <string.h>

[[deprecated]] void *rawmemchr(const void *s, int c);

okay so first thing: yes, that [[deprecated]] is right there in the synopsis. she is marked deprecated, and we'll get into why in a sec. and yeah, you need that #define _GNU_SOURCE line up top (peep feature_test_macros(7) for the whole lore), plus #include <string.h>. πŸŽ€


πŸ’… DESCRIPTION πŸ’…

rawmemchr() is giving memchr()'s chaotic cousin. It's similar to memchr(), BUT β€” and this is the whole personality β€” it assumes an instance of c lies somewhere in the memory area starting at the location pointed to by s. And when I say "assumes", I mean the programmer knows for certain. Like, knew knew. Not guessing. Not vibes-checking. Certain certain. πŸ‘‘

And here's the part where you hold my hand: if an instance of c is not found, the behavior is undefined. Not an error code, not a NULL, not a sad little return value. Undefined. She will just keep vibing through your memory like she pays rent there. πŸ’€

bestie please, use strlen(3) or memchr(3) instead. genuinely. i'm not being dramatic, i'm being a good friend. 😭

πŸ¦‹ RETURN VALUE πŸ¦‹

The rawmemchr() function returns a pointer to the matching byte. that's it, that's the whole return value, she's a simple girl ✨


πŸ‘‘ ATTRIBUTES πŸ‘‘

For an explanation of the terms used in this section, see attributes(7). πŸ“–

  • Interface: rawmemchr()
  • Attribute: Thread safety
  • Value: MT-Safe

so yeah β€” MT-Safe, multi-thread safe, she can hang in the group chat with everybody at once, no drama. 🫢


🌈 STANDARDS 🌈

GNU. πŸ‡¬πŸ‡³ (affectionate, that's just her house)


⭐ HISTORY ⭐

glibc 2.1. β€” she's been here since glibc 2.1, an elder icon, a legacy queen πŸ‘‘


πŸŽ€ SEE ALSO πŸŽ€

  • memchr(3) β€” the responsible one
  • strlen(3) β€” also the responsible one
  • strnul(3) β€” her other cousin, also a little unhinged iykyk

Linux man-pages 6.20 🌸 dated 2026-02-25 β€” that's the version and the date this page was serving, and that's a wrap bestie πŸ’–βœ¨ stay safe, don't call rawmemchr() unless you're absolutely certain, and go drink some water πŸ“πŸ’œ

πŸ“¦ 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