SDL_strtoull(3)

πŸ’– SDL_strtoull(3) πŸ’–

okay so bestie, welcome to the SDL3 FUNCTIONS corner of the manual, where today's main character is SDL_strtoull β€” she takes a string and hands you back an unsigned long long. no cap. 🫢


✨ NAME ✨

SDL_strtoull β€” parse an unsigned long long from a string. that's it, that's the vibe. πŸ’…


🌸 SYNOPSIS 🌸

#include <SDL3/SDL_stdinc.h>

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

look at her. three little args. iconic behavior honestly. πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea, bestie. if str starts with whitespace, those whitespace characters get skipped before anything tries to parse the number. like, they're just politely stepped over. 🧚

and if the parsed number does not fit inside an unsigned long long? it gets clamped to the maximum representable unsigned long long value. no overflow drama, no undefined chaos β€” just a hard little ceiling. periodt. πŸ”₯


πŸŽ€ FUNCTION PARAMETERS πŸŽ€

  • str β€” the null-terminated string to read. and listen. it must not be NULL. that's a real rule, not a suggestion, bestie. 😭
  • endp β€” if this one is not NULL, then the address of the first invalid character (i.e. the next character right after the parsed number) gets written to this pointer. so basically she tells you exactly where she stopped reading. obsessed. 🌸
  • base β€” the base of the integer to read. supported values are 0 and 2 to 36 inclusive. if it's 0, the base gets inferred from the number's prefix: 0x for hexadecimal, 0 for octal, decimal otherwise. she's flexible like that. ✨

πŸ’œ RETURN VALUE πŸ’œ

returns the parsed unsigned long long... or 0 if no number could be parsed. yeah, that's the whole thing. if nothing worked, you get a zero and you gotta deal with it. πŸ’€


🌈 THREAD SAFETY 🌈

it is safe to call this function from any thread. every thread. all of them. go wild, queen. πŸŽ‰


⭐ AVAILABILITY ⭐

this function is available since SDL 3.2.0. so if you're on something older... no she's not there yet, sorry babe. πŸ™ˆ


πŸ‘‘ SEE ALSO πŸ‘‘

the whole little friend group, fr fr:


lowkey reminder bestie: str can't be NULL, and out-of-range numbers get clamped, not wrapped. keep those two facts in your pocket and you're golden. 🫢

and that's the page!! brought to you by Simple Directmedia Layer, version SDL 3.4.18, page SDL_strtoull(3) β€” mwah, slay, go parse something gorgeous. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from