SDL_strrev(3)

πŸ’– SDL_strrev β€” the glow-up your string asked for πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where we take your sad little string and flip it like a mattress. this one's called SDL_strrev and she's iconic, but she comes with a warning label, so stay with me. πŸŽ€


✨ NAME ✨

SDL_strrev β€” reverse a string's contents. that's it, that's the whole job. slay. πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_stdinc.h>

char * SDL_strrev(char *str);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe: this function reverses a null-terminated string, and it does it in-place β€” meaning it edits the string you handed it, right there, no copy, no new buffer, no nothing. main character energy honestly. ✨

the content of the string gets reversed. the null-terminator character stays exactly where it belongs, at the end of the now-reversed string. it is NOT getting dragged along for the ride, bestie, it's holding the door. 🫢

WARNING, and I need you to actually read this one: this function reverses the _bytes_ of the string, NOT the codepoints. so if str is a UTF-8 string with Unicode codepoints > 127, this will ruin the string data. like, genuinely ruin it. 😭 you should only use this function on strings that are completely comprised of low ASCII characters. that's the rule. no exceptions. periodt.

πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • str β€” the string to reverse. she's the one getting flipped. πŸ’«

⭐ RETURN VALUE ⭐

returns str. that's right, it hands you back the very same pointer you gave it β€” which, again, is now reversed, because in-place is the whole thing. πŸ”₯


🌈 THREAD SAFETY 🌈

it is safe to call this function from any thread. go forth and multithread, you absolute legend. πŸ‘‘


πŸ’œ AVAILABILITY πŸ’œ

this function is available since SDL 3.2.0. if you're on anything older, she simply does not exist yet, sorry babe. πŸ’€


and that's the page!! brought to you by the Simple Directmedia Layer girlies, running SDL 3.4.18 β€” thanks for reading, go reverse something (that's low ASCII, please, I'm begging πŸ™ˆ). bye bestie, love u, drink water πŸ’–πŸŒΈβœ¨

πŸ“¦ where this page comes from