SDL_atoi(3)

πŸ’– SDL_atoi β€” the "string goes in, number comes out" glow-up πŸ’–

okay bestie, welcome to the SDL3 FUNCTIONS manual, page SDL_atoi(3). this one is short, sweet, and lowkey iconic. sit down, grab a boba, let's get into it ✨


🌸 NAME 🌸

SDL_atoi β€” parse an int from a string. that's it. that's the whole job. fr fr.


πŸŽ€ SYNOPSIS πŸŽ€

#include <SDL3/SDL_stdinc.h>

int SDL_atoi(const char *str);

like. look at her. one include, one function, one const char *. minimalist queen πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the tea: calling SDL_atoi(str) is equivalent to this:

(int)SDL_strtol(str, NULL, 10);

that's literally it. no secret sauce, no hidden extra steps, no plot twist. she's just SDL_strtol with base 10 and a NULL end pointer, then the result gets cast to int. the way that she does the thing and then hands it over 🫢

so if you were expecting something wild, nope. she's a wrapper. a cute little wrapper. and honestly? we love a function that knows exactly what she is πŸ’œ


🌈 FUNCTION PARAMETERS 🌈

  • str β€” the null-terminated string you want her to read. must not be NULL. like, genuinely, do not. that's the one boundary bestie 🚫

⭐ RETURN VALUE ⭐

she returns the parsed int. that's the gift. that's the whole present 🎁


πŸ”₯ THREAD SAFETY πŸ”₯

go off. it is safe to call this function from any thread. main character energy in every single thread, no cap πŸ‘‘


✨ AVAILABILITY ✨

this function has been available since SDL 3.2.0. so if you're on anything older... bestie. upgrade. it's giving ancient 😭


🧚 SEE ALSO 🧚

the whole number-parsing friend group. they all hang out. iykyk 🌸


and that's the page!! brought to you by Simple Directmedia Layer, version SDL 3.4.18, SDL_atoi(3). thanks for coming to my ted talk, go parse something responsibly, mwah πŸ’–πŸ’…βœ¨

πŸ“¦ where this page comes from