Your Browser is not longer supported
Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...
{{viewport.spaceProperty.prod}}
setvbuf - assign buffering to stream
&pagelevel(4)&pagelevel
Syntax | #include <stdio.h> int setvbuf(FILE *stream, char *buf, int type, size_t size); |
Description | setvbuf() may be used after the stream pointed to by stream has been associated with an open file but before any other operation has been performed on the stream. It causes the array pointed to by buf to be used instead of an automatically allocated buffer. If buf is a null pointer, all I/O is unbuffered.
type determines how stream is to be buffered, as follows: |
| _IOFBF
_IOLBF
_IONBF
| Full buffering of input and output Line buffering Unbuffered input and output |
| If buf is not a null pointer, the array it points to may be used instead of a buffer allocated by setvbuf() . size specifies the size of the buf array. The contents of the buf array at any given time are indeterminate. |
Return val. | 0 | if successful. |
| != 0
| if an invalid value was specified for type or if the request cannot be satisfied. errno is set to indicate the error. |
Errors | setvbuf() will fail if:
|
| EBADF
| The file descriptor underlying stream is not valid. |
Notes | A common source of error is to use an "automatic" variable (i.e. a variable of storage class auto ) as the buffer in a program block and then fail to close the file in the same block. Since a portion of buf is required for internal administration data of the stream, buf will contain less than size bytes when full. It is therefore preferable to use setvbuf() with automatically allocated buffers. Allocating a buffer of size bytes with setvbuf() does not necessarily imply that all of size bytes will be used for the buffer area. Applications should note that many implementations only provide line buffering on input from terminal devices. setvbuf() is executed for the file that is assigned to stream . This file can be either a POSIX file or a BS2000 file.
BS2000 If the blocking factor is explicitly defined with the BUFFER-LENGTH parameter of the SET-FILE-LINK command, the size of the area must correspond to this defined blocking size. (End) |
See also | fopen() , setbuf() , stdio.h , section “Streams”.
|