---
name: "SDL_ReadIO"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_ReadIO"
---

# SDL\_ReadIO(3)

Read from a data source.

## NAME

SDL\_ReadIO - Read from a data source.

## HEADER FILE

Defined in SDL3/SDL\_iostream.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**size\_t SDL\_ReadIO(SDL\_IOStream \*context, void \*ptr, size\_t size);**

## DESCRIPTION

This function reads up **size** bytes from the data source to the area pointed at by **ptr** . This function may read less bytes than requested.

This function will return zero when the data stream is completely read, and

**SDL\_GetIOStatus** () will return

**SDL\_IO\_STATUS\_EOF** . If zero is returned and the stream is not at EOF,  **SDL\_GetIOStatus** () will return a different error value and  **SDL\_GetError** () will offer a human-readable message.

## FUNCTION PARAMETERS

- *context*

  a pointer to an  **SDL\_IOStream**\
    structure.

- *ptr*

  a pointer to a buffer to read data into.

- *size*

  the number of bytes to read from the data source.

## RETURN VALUE

Returns the number of bytes read, or 0 on end of file or other failure; call  **SDL\_GetError** () for more information.

## THREAD SAFETY

This function is not thread safe.

## AVAILABILITY

This function is available since SDL 3.2.0.

## SEE ALSO

**•**(3), [**SDL\_WriteIO**(3)](/SDL_WriteIO/3.md), **•**(3), [**SDL\_GetIOStatus**(3)](/SDL_GetIOStatus/3.md)
