SDL_strtoul(3)

✨ SDL_strtoul ✨

okay bestie, welcome to the SDL_strtoul(3) page from the SDL3 FUNCTIONS era πŸ’– this one's a little string-to-number glow-up machine and honestly? it's giving useful.


🌸 NAME 🌸

SDL_strtoul β€” parse an unsigned long from a string. that's it, that's the vibe 🫢


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_stdinc.h>

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

πŸ’… DESCRIPTION πŸ’…

so like. if str starts with whitespace, those whitespace characters get skipped before it even tries to parse the number. no cap, it's just being polite and looking past the leading blanks ✨

and if the parsed number does not fit inside an unsigned long?? the result gets clamped to the maximum representable unsigned long value. not an error, not a crash, just a lil ceiling moment πŸ‘‘ it simply refuses to go past the max.


πŸ¦‹ FUNCTION PARAMETERS πŸ¦‹

  • str β€” the null-terminated string to read. must not be NULL. like, genuinely, don't do that πŸ™ˆ
  • 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 it's your little "and this is where the number stopped" receipt 🧾
  • 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). iconic detective behaviour πŸ”

🌈 RETURN VALUE 🌈

returns the parsed unsigned long, or 0 if no number could be parsed. yes, that means 0 is doing double duty, but that's just how it is bestie 😭


🧚 THREAD SAFETY 🧚

it is safe to call this function from any thread. go wild, multi-threaded queen πŸ’œ


⭐ AVAILABILITY ⭐

this function is available since SDL 3.2.0. so if you're on something older, that's a no from me πŸ’€


πŸ”₯ SEE ALSO πŸ”₯


and that's the whole page, bestie!! this lil cutie comes to you from Simple Directmedia Layer, version SDL 3.4.18, dated SDL_strtoul(3) β€” mwah, go parse something βœ¨πŸ’–πŸŽ€

πŸ“¦ where this page comes from