setbuf

Associates a buffer with a file after the file is open and before it has been read or written to.

Library:LibC
Classification:ANSI
Service:File and Directory I/O

Syntax

  #include <stdio.h> 
   
  void setbuf (
     FILE   *fp,   
     char   *buffer);
  

Parameters

fp

(IN) Points to the file.

buffer

(IN) Points to the buffer.

Remarks

The setbuf function associates a buffer with the file designated by fp. This function must be called after the file has been opened and before it has been read or written.

The buffer parameter has the following restrictions:

  • If the buffer parameter is NULL, all input/ output for the file pointed to by fp is completely unbuffered.

  • If the buffer parameter is not NULL, it must point to an array that is at least BUFSIZ characters in length, and all input/output is fully buffered. BUFSIZ is a constant defined in stdio.h.

See Also