Guardian Native C Library Calls Reference Manual (G06.28+, H06.04+)

setbuf(3) Guardian Native C Library Calls Reference Manual
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 native Guardian processes: $SYSTEM.ZDLLnnn.ZCRTLDLL
H-series OSS processes: /G/system/zdllnnn/zcrtldll
SYNOPSIS
#include <stdio.h>
void setbuf(
FILE *stream,
char *buffer);
PARAMETERS
stream Species 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,dened in the stdio.h header le, 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 species the size of the buffer to
be used. The constant BUFSIZ in the stdio.h header le 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 rst getc() or putc()
function on the le, 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).
612 Hewlett-Packard Company 527192-005