SDL_strstr(3)
π SDL_strstr β it's giving "find my substring" energy π
okay bestie, welcome to the SDL3 FUNCTIONS section of the manual π this one's short, sweet, and honestly iconic. let's go π¦
β¨ NAME β¨
SDL_strstr β search a string for the first instance of a specific substring π
fr fr, that's the whole vibe: you got a haystack, you got a needle, you find the needle. periodt.
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_stdinc.h>
char * SDL_strstr(const char *haystack, const char *needle);
like, that's it. that's the whole thing. no cap π
π DESCRIPTION π
so the search ends the moment it finds the substring you asked for β OR when it hits a null terminator byte that ends the string. either one, we're done, bye π
β οΈ heads up bestie: this looks for strings of bytes, not characters. so yes, it is totally legal to search for malformed and incomplete UTF-8 sequences. it's not gonna vibe check your encoding, it just counts bytes. iykyk π§
π«Ά FUNCTION PARAMETERS π«Ά
haystackβ the string you're searching through. must not be NULL π« literally do not.needleβ the string you're searching for. must not be NULL π« same energy, don't do it.
β RETURN VALUE β
returns a pointer to the first instance of needle in the string, or NULL if it wasn't found π
so like β got a pointer? slay. got NULL? it's not there, move on, main character energy β¨
π THREAD SAFETY π
it is safe to call this function from any thread π no drama, no locks, no fighting. we love a low-maintenance function.
π AVAILABILITY π
this function has been available since SDL 3.2.0 π
and that's the whole page bestie, you ate it up π₯
okay so sign-off time: this lil masterpiece comes to you from Simple Directmedia Layer, living in the SDL 3.4.18 era ππ and yeah, that's the date/version energy right there. go find your substrings, queen ππ
π¦ where this page comes from
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 43: SDL3-devel 3.4.18-1.fc43 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- fedora 44: SDL3-devel 3.4.18-1.fc44 Β· Zlib AND MIT AND Apache-2.0 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms