Guardian C Library Calls Reference Manual
setbuf
3-158 128833—Guardian TNS C Library Calls Reference Manual
Reference to Library Calls
setbuf
The setbuf function attaches a user-supplied buffer to a file opened for ANSI I/O. This
buffer is then used for all I/O buffering, thus freeing the system resources normally used
for this purpose.
stream
denotes a file opened for ANSI I/O.
buffer
points to the new file buffer. *buffer must accommodate at least BUFSIZ elements.
Return Value
none.
Usage Guidelines
•
You must call this function before any I/O is performed.
•
If buffer is NULL, this function has the same effect as setnbuf.
•
BUFSIZ is a predefined object-like macro that specifies the size in bytes of the
buffers used for streams. It is defined in the <stdioh> header.
Example
In this example, the setbuf function attaches the buffer named buf to $a.b.c:
#include <stdioh>
FILE *fp;
char buf[BUFSIZ];
fp = fopen("a.b.c ", "r+");
/* ... */
setbuf(fp, buf);
#include <stdioh>
void setbuf(FILE *stream, char *buffer);