SDL_strtol(3)
β¨ SDL_strtol β¨
okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, page SDL_strtol(3). this one is lowkey iconic and you're gonna eat it up π
πΈ NAME πΈ
SDL_strtol β parse a long out of a string, fr fr.
π¦ SYNOPSIS π¦
#include <SDL3/SDL_stdinc.h>
long SDL_strtol(const char *str, char **endp, int base);
π DESCRIPTION π
so here's the vibe. if str starts with whitespace, those whitespace characters get skipped before anything tries to parse the number. like, they're just not the moment, you know? π«Ά
and if the parsed number doesn't fit inside a long?? it gets clamped to the minimum and maximum representable long values. no overflow drama, just vibes, it gets squished into range. periodt.
π FUNCTION PARAMETERS π
strβ the null-terminated string you wanna read. Must not beNULL. like. do not. πendpβ if it's notNULL, the address of the first invalid character (aka the next character after the parsed number) gets written to this pointer. it's giving "here's where I stopped reading" β¨baseβ the base of the integer you're reading. supported values are0and2to36inclusive. if it's0, the base gets inferred from the number's prefix (0xfor hexadecimal,0for octal, decimal otherwise). so smart, so intuitive, we love a self-aware base π
β RETURN VALUE β
returns the parsed long. or 0 if no number could be parsed. that's it. that's the whole thing. π
π THREAD SAFETY π
it is safe to call this function from any thread. no cap. go wild, bestie. π§
π AVAILABILITY π
this function is available since SDL 3.2.0. so if you're on something older... girl. upgrade. π
π₯ SEE ALSO π₯
SDL_atoi(3)SDL_atof(3)SDL_strtoul(3)SDL_strtoll(3)SDL_strtoull(3)SDL_strtod(3)SDL_ltoa(3)SDL_wcstol(3)
and that's the whole page, bestie π this lil masterpiece lives in Simple Directmedia Layer, version SDL 3.4.18, dated SDL_strtol(3). go parse something gorgeous πβ¨
π¦ 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