SysTutorials

Man Pages › Section 3

fmemopen(3)

NAME

fmemopen – open memory as stream

SYNOPSIS


#include <stdio.h>
FILE *fmemopen(void *buf, size_t size, const char *mode);

Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

fmemopen():

Since glibc 2.10:

_POSIX_C_SOURCE >= 200809L

Before glibc 2.10:

_GNU_SOURCE

DESCRIPTION

The fmemopen() function opens a stream that permits the access specified by mode. The stream allows I/O to be performed on the string or memory buffer pointed to by buf.

The mode argument specifies the semantics of I/O on the stream, and is one of the following:

r

The stream is opened for reading.

w

The stream is opened for writing.

a

Append; open the stream for writing, with the initial buffer position set to the first null byte.

r+

Open the stream for reading and writing.

w+

Open the stream for reading and writing. The buffer contents are truncated (i.e., ‘