sdlSscanf function

int sdlSscanf(
  1. String? text,
  2. String? fmt,
  3. Pointer<NativeType> arg2
)

This works exactly like sscanf() but doesn't require access to a C runtime.

Scan a string, matching a format string, converting each '%' item and storing it to pointers provided through variable arguments.

\param text the string to scan. Must not be NULL. \param fmt a printf-style format string. Must not be NULL. \param ... a list of pointers to values to be filled in with scanned items. \returns the number of items that matched the format string.

\threadsafety It is safe to call this function from any thread.

\since This function is available since SDL 3.1.3.

extern SDL_DECLSPEC int SDLCALL SDL_sscanf(const char *text, SDL_SCANF_FORMAT_STRING const char *fmt, ...) SDL_SCANF_VARARG_FUNC(2)

Implementation

int sdlSscanf(String? text, String? fmt, Pointer<NativeType> arg2) {
  final sdlSscanfLookupFunction = libSdl3.lookupFunction<
      Int32 Function(
          Pointer<Utf8> text, Pointer<Utf8> fmt, Pointer<NativeType> arg2),
      int Function(Pointer<Utf8> text, Pointer<Utf8> fmt,
          Pointer<NativeType> arg2)>('SDL_sscanf');
  final textPointer = text != null ? text.toNativeUtf8() : nullptr;
  final fmtPointer = fmt != null ? fmt.toNativeUtf8() : nullptr;
  final result = sdlSscanfLookupFunction(textPointer, fmtPointer, arg2);
  calloc.free(textPointer);
  calloc.free(fmtPointer);
  return result;
}