setbuf()                 Control Stream Buffering
 
 #include   <stdio.h>
 
 void       setbuf(stream,buffer);
 FILE       *stream;                     Pointer to file structure
 char       *buffer;                     User-allocated buffer
 
    setbuf allows the user to control buffering, by causing the specified
    'buffer' to be used for I/O buffering, instead of the automatically
    allocated buffer.  'stream' must refer to an open file.  If 'buffer'
    is NULL, the stream is unbuffered; otherwise it is fully buffered.
    'buffer' must point to a character array BUFSIZE bytes long. (BUFSIZE
    is defined in <stdio.h>).
 
    Returns:    There is no return value.
 
      Notes:    'stderr' and 'stdaux' are unbuffered by default.  They
                can be assigned buffers with setbuf().
 
  -------------------------------- Example ---------------------------------
 
    The following statements open two files and assign a user-specified
    buffer to one.
 
         #include <stdio.h>
 
         char buf[BUFSIZE];
         FILE *stream1, *stream2;
 
         main()
         {
             if((stream1 = fopen("data1","r")) != NULL &&
                 stream2 = fopen("data2","w")) != NULL)  {
                     setbuf(stream1,buf);
             }
         }

Seealso:



This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster