SDL_strtoll(3)

πŸ’– SDL_strtoll πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS corner of the manual, page SDL_strtoll(3) β€” she parses a long long out of a string and she does it flawlessly. ✨


πŸŽ€ NAME πŸŽ€

SDL_strtoll β€” parse a long long from a string. that's it, that's the whole job, and she ate. πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_stdinc.h>

long long SDL_strtoll(const char *str, char **endp, int base);

πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the vibe. if str starts with whitespace, those whitespace characters get skipped before she even attempts to parse the number. she's not gonna let a lil space ruin the moment, she's better than that. 🫢

and if the parsed number does not fit inside a long long? the result gets clamped to the minimum and maximum representable long long values. no cap. she's not gonna overflow on you, she's just gonna give you the biggest or smallest thing she's got and move on. iconic behaviour honestly. πŸ‘‘


⭐ FUNCTION PARAMETERS ⭐

  • str β€” the null-terminated string to read. and bestie, she means it: this must not be NULL. 🚫
  • endp β€” if it's not NULL, the address of the first invalid character (i.e. the next character after the parsed number) gets written to this pointer. so you can see exactly where she stopped reading, iykyk. πŸ“
  • base β€” the base of the integer to read. supported values are 0 and 2 to 36 inclusive. and if it's 0, the base gets inferred from the number's prefix: 0x for hexadecimal, 0 for octal, decimal otherwise. she's reading the room (and the prefix). πŸ”₯

πŸ’œ RETURN VALUE πŸ’œ

returns the parsed long long, or 0 if no number could be parsed. simple, clean, no drama. (well β€” 0 is also a valid parse, so like, read endp if you need to tell them apart, that's the whole point of her.) 😭


🌈 THREAD SAFETY 🌈

it is safe to call this function from any thread. she's multithreaded-friendly, she contains multitudes. ✨


πŸ‘‘ AVAILABILITY πŸ‘‘

this function is available since SDL 3.2.0. so if you're on something older... bestie. upgrade. πŸ™ˆ


πŸ“ SEE ALSO πŸ“


and that's the whole page, babe. this lil gem lives in Simple Directmedia Layer land, version SDL 3.4.18, page SDL_strtoll(3). go forth and parse responsibly. mwah. πŸ’–πŸ§šπŸŽ€

πŸ“¦ where this page comes from