C Tutorial/stdio.h/setvbuf

Материал из C\C++ эксперт
Перейти к: навигация, поиск

setvbuf

Item Value Header file stdio.h Declaration int setvbuf(FILE *stream, char *buf, int mode, size_t size); Return returns zero on success, nonzero on failure.

Function sets the buffer for stream to be buffer, with a size of size.

Possible values of mode are _IOFBF, _IONBF, and _IOLBF.

  1. _IOFBF: full buffering.
  2. _IOLBF: line buffered.
  3. _IONBF: no buffering.


<source lang="cpp">#include <stdio.h> int main () {

 FILE *fp;
 fp=fopen ("myfile.txt","w");
 setvbuf ( fp , NULL , _IOFBF , 1024 );
 // File operations here
 fclose (fp);
 return 0;

}</source>