Library /sys$common/syshlp/helplib.hlb  —  CRTL  setvbuf  Description
    You can use the setvbuf function after the file is opened but
    before any I/O operations are performed.

    The C RTL provides the following types of ANSI-conforming file
    buffering:

    In line-buffered I/O, characters are buffered in an area of
    memory until a new-line character is seen, at which point the
    appropriate RMS routine is called to transmit the entire buffer.
    Line buffering is more efficient than unbuffered I/O since it
    reduces the system overhead, but it delays the availability of
    the data to the user or disk on output.

    In fully buffered I/O, characters are buffered in an area of
    memory until the buffer is full, regardless of the presence of
    break characters. Full buffering is more efficient than line
    buffering or unbuffered I/O, but it delays the availability of
    output data even longer than line buffering.

    Use the values _IOLBF and _IOFBF defined in <stdio.h> for the
    type argument to specify line-buffered and fully buffered I/O,
    respectively.

    If file_ptr specifies a terminal device, the Compaq C RTL uses
    line-buffered I/O; otherwise, it uses fully buffered I/O.

    Please note that the previously documented value _IONBF is not
    supported.

    The Compaq C RTL automatically allocates a buffer to use for each
    I/O stream, so there are several buffer allocation possibilities:

    o  If buffer is not a NULL pointer and size is not smaller than
       the automatically allocated buffer, then setvbuf uses buffer
       as the file buffer.

    o  If buffer is a NULL pointer or size is smaller than the
       automatically allocated buffer, the automatically allocated
       buffer is used as the buffer area.

    o  If buffer is a NULL pointer and size is larger than the
       automatically allocated buffer, then setvbuf allocates a new
       buffer equal to the specified size and uses that as the file
       buffer.

    User programs must not depend on the contents of buffer once I/O
    has been performed on the stream. The Compaq C RTL might or might
    not use buffer for any given I/O operation.

    Generally, it is unnecessary to use setvbuf or setbuf to control
    the buffer size used by the Compaq C RTL. The automatically
    allocated buffer sizes are chosen for efficiency based on the
    kind of I/O operations performed and the device characteristics
    (such as terminal, disk, or socket).

    The setvbuf and setbuf functions are useful to introduce
    buffering for improved performance when writing a large amount of
    text to the stdout stream. This stream is unbuffered by default
    when bound to a terminal device (the normal case), and therefore
    incurs a large number of OpenVMS buffered I/O operations unless
    Compaq C RTL buffering is introduced by a call to setvbuf or
    setbuf.

    The setvbuf function is used only to control the buffering used
    by the Compaq C RTL, not the buffering used by the underlying RMS
    I/O operations. You can modify RMS default buffering behavior by
    specifying various values for the ctx, fop, rat, gbc, mbc, mbf,
    rfm, and rop RMS keywords when the file is opened by the creat,
    freopen or open functions.
Close Help