API reference / Files, memory, and strings
SDL_LoadFile
Function, SDL3
Reads a full file into new memory, and adds a null character at the end.
Declaration
#include <SDL3/SDL.h>
void * SDL_LoadFile(const char *file, size_t *datasize);Parameters
file | The path of the file. |
datasize | The address of a value for the size in bytes, or NULL. |
Return value
A pointer to the data, or NULL on failure.
Example
file_text = SDL_LoadFile(path, NULL);See this code run in Read a file. Download the full program (.zip)
Notes
- Free the data with
SDL_free.
In SDL2
The name is the same.