From HI-TECH C for CP/M Fan WIKI(EN)
Jump to: navigation, search



#include  <stdio.h>

int setvbuf(FILE * stream, char * buf, int mode, size_t size);
void      setbuf(FILE * stream, char * buf)


The setvbuf() function allows the buffering behaviour of a STDIO stream to be altered. It supersedes the function setbuf() which is retained for backwards compatibility. The arguments to setvbuf() are as follows: stream designates the STDIO stream to be affected; buf is a pointer to a buffer which will be used for all subsequent I/O operations on this stream. If buf is null, then the routine will allocate a buffer from the heap if necessary, of size BUFSIZ as defined in <stdio.h>. mode may take the values _IONBF, to turn buffering off completely, _IOFBF, for full buffering, or _IOLBF for line buffering. Full buffering means that the associated buffer will only be flushed when full, while line buffering means that the buffer will be flushed at the end of each line or when input is requested from another STDIO stream. size is the size of the buffer supplied. For example:

setvbuf(stdout, my_buf, _IOLBF, sizeof my_buf);

If a buffer is supplied by the caller, that buffer will remain associated with that stream even over fclose(), fopen() calls until another setvbuf() changes it.


fopen, freopen, fclose