API reference / Files, memory, and strings
SDL_snprintf
Function, SDL3
Writes formatted text into an array, as snprintf does. It never writes past the size that you give.
Declaration
#include <SDL3/SDL.h>
int SDL_snprintf(char *text, size_t maxlen, const char *fmt, ...);Parameters
text | The destination array. |
maxlen | The size of the array in bytes. |
fmt | A format string. |
... | The values for the format string. |
Return value
The length of the full text. A result of maxlen or more means that the text was cut.
Example
SDL_snprintf(text, sizeof(text), "Clicks: %d", clicks);See this code run in Draw text. Download the full program (.zip)
In SDL2
The name is the same.