STDIOBUF(3C++)

NAME
stdiobuf - buffer and stream classes for use with C stdio

SYNOPSIS

#include <stdiostream.h> // includes <iostream.h> and <stdio.h>

class stdiobuf : public streambuf {
public:
	stdiobuf(FILE*);
	FILE*	stdiofile();
};

class stdiostream : public ios {
public:
	stdiostream(FILE*);
	stdiobuf* rdbuf();
};

DESCRIPTION

The stdiobuf class is a specialization of streambufs using a C stdio FILE as an intermediary to an actual file which is the source or destination of characters. The basic streambuf operations are as described in sbufprot(3C++) and sbufpub(3C++). Input, output, and seek operations are reflected in changes to the associated FILE. The seek functions are implemented in terms of fseek(), for example.

The stdiostream provides a C++ interface to a C stdio FILE. It has a stdiobuf as its buffer. It is not a full implementation of iostreams; it has only the buffer-class and ios-class functionality. C++ I/O is done via per-character calls to the C stdio getc() and putc() functions. There is no normal buffering, since that would break synchronization of the C and C++ accesses.

The only reason to use either of these classes is to provide a way to mix C stdio code and C++ iostream-like code on the same file. Prefer to use filebuf and fstream, which are far more efficient, for new code.

  stdiobuf functions

stdiobuf(fp)
    Constructs a stdiobuf attached to the FILE structure pointed to by fp.

FILE* fp = siobuf.stdiofile()
    Returns a pointer to the FILE structure associated with siobuf.

  stdiostream functions

stdiostream(fp)
    Constructs a stdiostream attached to the FILE structure pointed to by fp.

stdiobuf* sbp = siostr.rdbuf()
    Returns a pointer to the stdiobuf associated with siostr. This is the same as ios::rdbuf(), except that the return type is specifically a stdiobuf.

SEE ALSO

ios.intro(3C++), ios(3C++), sbufprot(3C++), sbufpub(3C++), stdio(3V),

C++ 4.1 Library Reference Manual:

C++ 4.1 Library Reference Manual:

Chapter 4, "The Iostream Library",
            Chapter 4, "The Iostream Library",