SDL_strcmp(3)
π SDL_strcmp(3) π
the SDL3 functions girlies presentβ¦ a whole function for comparing two null-terminated UTF-8 strings, and honestly? iconic. welcome to the SDL_strcmp page, bestie π«Ά
β¨ NAME β¨
SDL_strcmp β compare two null-terminated UTF-8 strings. that's it, that's the job π
πΈ SYNOPSIS πΈ
#include <SDL3/SDL_stdinc.h>
int SDL_strcmp(const char *str1, const char *str2);
π¦ DESCRIPTION π¦
okay so here's the tea β β because of the whole nature of UTF-8 encoding, this function just works with Unicode strings. like, no extra effort needed. why? because effectively all it does is compare bytes until it hits a null-terminating character. that's the whole vibe. byte by byte until the \0 shows up, periodt.
and also, again because UTF-8 is just Like That, you can totally pair this with SDL_qsort() to put your strings in (roughly) alphabetical order. note the roughly β it's giving "good enough", not "perfectly sorted by your language's collation rules". it ate but it's not doing the most π
π FUNCTION PARAMETERS π
str1β the first string to compare.NULLis not permitted! like, do NOT. πstr2β the second string to compare.NULLis not permitted! same energy, same warning. π«
β RETURN VALUE β
- returns less than zero if
str1is "less than"str2π - returns greater than zero if
str1is "greater than"str2π - returns zero if the strings match exactly β¨ (a perfect match, main character energy π)
π§ THREAD SAFETY π§
it is safe to call this function from any thread. no cap. go wild, queen π
π AVAILABILITY π
this function is available since SDL 3.2.0. old enough to be trusted, young enough to be cute π
lowkey reminder: no NULLs allowed in either spot. fr fr. protect your pointers bestie π
and that's the whole page, you understood it perfectly, slay π β¨
signing off with love from the Simple Directmedia Layer babes β this is SDL 3.4.18, mwah πππ¦
π¦ 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