SDL_strrchr(3)
π SDL_strrchr β the SDL3 glow-up π
okay bestie, welcome to SDL_strrchr(3), one of the SDL3 FUNCTIONS β¨ it's giving "find the last one" energy and honestly? iconic.
πΈ NAME πΈ
SDL_strrchr β Search a string for the last instance of a specific byte. that's it, that's the whole vibe π
β¨ SYNOPSIS β¨
#include <SDL3/SDL_stdinc.h>
char * SDL_strrchr(const char *str, int c);
like... she's short, she's simple, she works. periodt. π
π¦ DESCRIPTION π¦
so the tea is: the search must keep going until it hits a null terminator byte, because that's what ends the string. no skipping ahead, no shortcuts, she's committed to the bit π«Ά
and now the part everyone gets wrong β note that this looks for _bytes_, not _characters_. so you literally cannot match against a Unicode codepoint > 255, regardless of character encoding. not "shouldn't", not "it's discouraged" β cannot. the byte is the byte, bestie π
π FUNCTION PARAMETERS π
strβ the string to search. Must not beNULL. like, do not. πcβ the byte value to search for.
β RETURN VALUE β
Returns a pointer to the last instance of c in the string, or NULL if it's not found. so either you get your lil pointer back or you get NULL and you deal with it π
π THREAD SAFETY π
It is safe to call this function from any thread. yes queen, no locking drama, no "only from the main thread" nonsense, just go off π₯
π AVAILABILITY π
This function is available since SDL 3.2.0. so if you're on something older... it's not there, sorry babe π
fr fr, the one thing to remember: it's the last byte, and it's a byte not a character. iykyk π
stay hydrated, read your return values, and go find that last byte bestie πβ¨πΈπ¦
β written with love from the Simple Directmedia Layer girlies, straight out of SDL 3.4.18, and yeah, this is SDL_strrchr(3) signing off ππ
π¦ 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