Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C 6.0 - <b>setbuf() control stream buffering</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 setbuf()                Control Stream Buffering

 #include   <stdio.h>

 void       setbuf(stream,buffer);
 FILE       *stream;                     Pointer to FILE structure
 char       *buffer;                     User-allocated buffer

    setbuf() provides for user-controlled 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,
    but a file which has not been read from nor written to.  If 'buffer'
    is NULL, the stream is unbuffered; otherwise it is fully buffered.
    'buffer' must point to a character array BUFSIZ bytes long. (BUFSIZ
    is defined in <stdio.h>).

    Returns:    No return value.

      Notes:    'stderr' and 'stdaux' can be assigned buffers with
                setbuf().  They are unbuffered by default.

   -------------------------------- Example ---------------------------------

    The following statements open two files and assign a user-specified
    buffer to one.

           #include <stdio.h>

           char buf[BUFSIZ];
           FILE *stream1, *stream2;

           main()
           {
               if((stream1 = fopen("data1","w+")) != NULL &&
                   stream2 = fopen("data2","w+")) != NULL)  {
                       setbuf(stream1,buf);
               }
           }


See Also: fflush() fopen() fclose() setvbuf()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson