Open System Services Library Calls Reference Manual (G06.29+, H06.08+, J06.03+)
OSS Library Calls (s) setbuf(3)
NAME
setbuf - Assigns buffering to a stream
LIBRARY
G-series native Guardian processes: $SYSTEM.SYSnn.ZCRTLSRL
G-series native OSS processes: /G/system/sysnn/zcrtlsrl
H-series and J-series native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
32-bit H-series and J-series OSS processes: /G/system/zdllnnn/zcrtldll
64-bit H-series and J-series OSS processes: /G/system/zdllnnn/ycrtldll
SYNOPSIS
#include <stdio.h>
void setbuf(
FILE *stream,
char *buffer);
PARAMETERS
stream Specifies the input/output stream.
buffer Points to a character array.
DESCRIPTION
The setbuf( ) function causes the character array pointed to by the buffer parameter to be used
instead of an automatically allocated buffer. Use the setbuf( ) function after a stream has been
opened, but before it is read or written.
If the buffer parameter is a null-character pointer, input/output is unbuffered.
A constant, BUFSIZ, defined in the stdio.h header file, tells how large an array is needed:
char buf[BUFSIZ];
If the buffer parameter is not a null-character pointer, the array it points to is used for buffering
instead of an automatically allocated buffer. The size parameter specifies the size of the buffer to
be used. The constant BUFSIZ in the stdio.h header file is one buffer size. If input/output is
unbuffered, the buffer and size parameters are ignored.
A buffer is normally obtained from the malloc( ) function at the time of the first getc( ) or putc( )
function on the file, except that the standard error stream, stderr, is normally not buffered.
Output streams directed to terminals are always either line buffered or unbuffered.
NOTES
A common source of error is allocating buffer space as an automatic variable in a code block,
and then failing to close the stream in the same block.
RETURN VALUES
The setbuf( ) function does not return values.
ERRORS
None. The setbuf( ) function does not set errno.
RELATED INFORMATION
Functions: fopen(3), fread(3), getc(3), getwc(3), malloc(3), putc(3), putwc(3), setvbuf(3).
527187-017 Hewlett-Packard Company 6−29