LabWindows/CVI

Content Type
Programming Language
Current manual
Table of Contents

setvbuf

setvbuf

int setvbuf (FILE *stream, char buffer[], int bufferingMode, size_t bufferSize);

Purpose

Specifies how to buffer the I/O stream. The mode of the stream can be set to full buffering, line buffering, or no buffering. If no buffer is specified, the system dynamically allocates one.

Parameters

Input
Name Type Description
stream FILE * Contains a pointer to the stream that has its buffering mode specified. This stream must be associated with an open file with no operations performed on it for the function to work correctly.
bufferingMode int Specifies the desired buffering mode for the stream. The following gives a description of the selections available:
Mode Value (int) Description
Full _IOFBF (2) Causes I/O to be fully buffered. Read and write operations involving a small number of bytes go through an in-memory buffer. The buffer is flushed only if it is full, if fflush is called, or if an input operation is completing. Buffering can significantly reduce execution time over multiple I/O operations.
Line _IOLBF (1) Causes I/O to be line buffered. This is the same as full buffering except that the buffer is flushed when a newline character is written.
None _IONBF (0) Causes I/O to be unbuffered. Each read or write operation acts directly on the file. If each operation involves only a small number of bytes, multiple operations can be very slow.
bufferSize size_t Contains the size of the buffer that is used for the specified stream. If the input to buffer is not NULL, the value input to this parameter must be less than or equal to the number of bytes in the specified buffer.
Output
Name Type Description
buffer char [] Contains a pointer to the I/O buffer that is used. If NULL is entered into this parameter, this function dynamically allocates the specified size. The contents of this buffer at any time are indeterminate.
Note Note  This array must be declared with at least as many elements as specified in the bufferSize parameter.

Return Value

Name Type Description
status int Contains the resulting status of the function. If successful, setvbuf returns 0. If an error occurs, setvbuf returns a nonzero value and sets errno to a nonzero value.

Additional Information

Library: ANSI C Library

Include file: ansi_c.h

LabWindows/CVI compatibility: LabWindows/CVI 3.0 and later

Was this information helpful?