On this page
  1. setvbuf
  2. Include
  3. Signature & Overview
  4. Notes & Pitfalls
  5. Example

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

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