SDL_ltoa(3)
β¨ SDL_ltoa β¨
okay bestie, welcome to the SDL3 FUNCTIONS corner of the man pages, this one's SDL_ltoa(3) and she's here to turn your long integer into a string π
πΈ NAME πΈ
SDL_ltoa β convert a long integer into a string. that's it, that's the job, and she does it flawlessly π
π SYNOPSIS π
#include <SDL3/SDL_stdinc.h>
char * SDL_ltoa(long value, char *str, int radix);
π¦ DESCRIPTION π¦
so here's the tea β β this one requires you to specify a radix for the string format. like, no radix, no conversion, she's not guessing for you.
- specifying
10produces a decimal number 16gives you hexadecimal- etc., you get the vibe β¨
and the radix must be in the range of 2 to 36. that's the whole range, don't try to be cute with it.
π GIRL. WARNING. this function will overflow a buffer if str is not large enough to hold the output! no cap, it will just keep writing. it is not checking. it does not care. π
so if you're not about that life, it may be safer to use SDL_snprintf to clamp output, or SDL_asprintf to allocate a buffer. otherwise? it genuinely doesn't hurt to allocate much more space than you expect to use β and bestie, don't forget the possible negative signs, the null terminator bytes, etc. those little guys add up π«Ά
π FUNCTION PARAMETERS π
valueβ the long integer to convert. your raw number, the main character πstrβ the buffer to write the string into. please make it big enough, i am begging πradixβ the radix to use for string generation.2through36, that's the rule β
π RETURN VALUE π
returns str. that's it. she hands you back the buffer you gave her, iconic behaviour honestly π
π§ THREAD SAFETY π§
it is safe to call this function from any thread. yes bestie, go wild, thread away β¨
β AVAILABILITY β
this function is available since SDL 3.2.0. so if you're on something older... no she's not there yet π
π₯ SEE ALSO π₯
go read those too, they're the whole friend group π«Ά
mwah π this has been your girl from the Simple Directmedia Layer squad, running SDL 3.4.18 energy, and yeah β this was SDL_ltoa(3), periodt. πβ¨π¦
π¦ 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