| Types and objects | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Defined in header <stdio.h> | ||
void setbuf(FILE *stream,char *buffer); | (until C99) | |
void setbuf(FILE*restrict stream,char*restrict buffer); | (since C99) | |
#define BUFSIZ /*unspecified*/ | ||
Sets the internal buffer to use for stream operations. It should be at leastBUFSIZ characters long.
Ifbuffer is not null, equivalent tosetvbuf(stream, buffer,_IOFBF,BUFSIZ).
Ifbuffer is null, equivalent tosetvbuf(stream,NULL,_IONBF,0), which turns off buffering.
Contents |
| stream | - | the file stream to set the buffer to |
| buffer | - | pointer to a buffer for the stream to use. If a null pointer is supplied, the buffering is turned off |
None.
IfBUFSIZ is not the appropriate buffer size,setvbuf can be used to change it.
setvbuf should also be used to detect errors, sincesetbuf does not indicate success or failure.
This function may only be used afterstream has been associated with an open file, but before any other operation (other than a failed call tosetbuf/setvbuf).
A common error is setting the buffer of stdin or stdout to an array whose lifetime ends before the program terminates:
setbuf may be used to disable buffering on streams that require immediate output.
Output:
ab
| sets the buffer and its size for a file stream (function)[edit] | |
C++ documentation forsetbuf | |