Next: , Previous: , Up: Stdio   [Contents][Index]


4.56 setbuffer—specify full buffering for a file or stream with size

Synopsis

#include <stdio.h>
void setbuffer(FILE *fp, char *buf, int size);

Description
setbuffer specifies that output to the file or stream identified by fp should be fully buffered. All output for this file will go to a buffer (of size size). Output will be passed on to the host system only when the buffer is full, or when an input operation intervenes.

You may, if you wish, supply your own buffer by passing a pointer to it as the argument buf. It must have size size. You can also use NULL as the value of buf, to signal that the setbuffer function is to allocate the buffer.


Warnings
You may only use setbuffer before performing any file operation other than opening the file.

If you supply a non-null buf, you must ensure that the associated storage continues to be available until you close the stream identified by fp.


Returns
setbuffer does not return a result.


Portability
This function comes from BSD not ANSI or POSIX.

Supporting OS subroutines required: close, fstat, isatty, lseek, read, sbrk, write.