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, usestrlen(3)ormemchr(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 onestrlen(3)β also the responsible onestrnul(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
- 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