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