On this page
setvbuf
Prev: rename | Up: stdio.h | Next: tmpfile
Rel: stdio.h, stdio.h & File I/O Guide
Ref: cppreference — setvbuf
Tags: #public #prog #c #stdlib #stdio #tier/specialized
Include
#include <stdio.h>
Signature & Overview
int setvbuf(FILE *restrict stream, char *restrict buf, int mode, size_t size);
Sets stream buffering mode (_IOFBF full, _IOLBF line, _IONBF unbuffered) before any I/O occurs.
Notes & Pitfalls
- Must be called immediately after
fopen(), before any read/write:_IOFBF(full),_IOLBF(line),_IONBF(unbuffered).
Example
#include <assert.h>
#include <stdio.h>
int main(void) {
FILE *f = tmpfile();
assert(setvbuf(f, NULL, _IONBF, 0) == 0);
fclose(f);
}
Linked from
Related notes
- tuts/c/stdlib/stdio/rename Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/tmpfile Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio Linked here; links to this page; shared tags: #c, #prog, #stdio, #stdlib
- tuts/c/stdlib/stdio_and_file_io Linked here; shared tags: #c, #prog, #stdlib
- tuts/c/stdlib/stdio/fclose shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/feof shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/ferror shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/fflush shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/fgets shared tags: #c, #prog, #stdio, #stdlib, #tier
- tuts/c/stdlib/stdio/fopen shared tags: #c, #prog, #stdio, #stdlib, #tier