sdlAtoi function
Parse an int
from a string.
The result of calling SDL_atoi(str)
is equivalent to
(int)SDL_strtol(str, NULL, 10)
.
\param str The null-terminated string to read. Must not be NULL.
\returns The parsed int
.
\threadsafety It is safe to call this function from any thread.
\since This function is available since SDL 3.1.3.
\sa SDL_atof \sa SDL_strtol \sa SDL_strtoul \sa SDL_strtoll \sa SDL_strtoull \sa SDL_strtod \sa SDL_itoa
extern SDL_DECLSPEC int SDLCALL SDL_atoi(const char *str)
Implementation
int sdlAtoi(String? str) {
final sdlAtoiLookupFunction = libSdl3.lookupFunction<
Int32 Function(Pointer<Utf8> str),
int Function(Pointer<Utf8> str)>('SDL_atoi');
final strPointer = str != null ? str.toNativeUtf8() : nullptr;
final result = sdlAtoiLookupFunction(strPointer);
calloc.free(strPointer);
return result;
}