---
name: "buffer_get"
section: "3diet"
platform: "linux"
package: "libowfat-dev"
version: "0.28-2"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/buffer_get/3diet"
---

# buffer\_get(3diet)

read binary data from buffer

## NAME

buffer\_get - read binary data from buffer

## SYNTAX

**#include \<buffer.h\>**

ssize\_t **buffer\_get**(buffer\* *b*,char\* *x*,size\_t *len*);

## DESCRIPTION

Normally buffer\_get copies data to *x*\[0\], *x*\[1\], ..., *x*\[*len*-1\] from the beginning of a string stored in preallocated space; removes these *len* bytes from the string; and returns *len*.

If, however, the string has fewer than *len* (but more than 0) bytes, buffer\_get copies only that many bytes, and returns that number.

If the string is empty, buffer\_get first uses a **read operation** to feed data into the string. The **read operation** may indicate end of input, in which case buffer\_get returns 0; or a read error, in which case buffer\_get returns -1, setting *errno* approporiately.

The preallocated space and the **read operation** are specified by *b*. You must initialize **b** using buffer\_init before calling buffer\_get (or use the pre-initialized buffer\_0).

## SEE ALSO

[buffer\_init(3)](/buffer_init/3.md), [buffer\_feed(3)](/buffer_feed/3.md), [buffer\_peek(3)](/buffer_peek/3.md), [buffer\_seek(3)](/buffer_seek/3.md), [buffer(3)](/buffer/3.md)
