setbuf

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

Local Servers:nonblocking
Remote Servers:nonblocking
Classification:ANSI
Platform:NLM
Service:Stream 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.

Return Values

The setbuf function returns no value.

Remarks

The setbuf function can be used to associate a buffer with the file designated by fp. If this function is used, it must be called after the file has been opened and before it has been read or written. If the argument buffer is NULL, then all input/ output for the file pointed to by fp is completely unbuffered. If the argument buffer is not NULL, then 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

fopen, setvbuf

setbuf Example

  #include <stdio.h> 
    
  main ()  
  {  
     char    *buffer;  
     FILE    *fp;  
     fp = fopen ("data.fil", "r");  
     buffer = malloc (BUFSIZ);  
     setbuf (fp, buffer);  
     fclose(fp);  
  }