Compartir a través de


Input/Output Streams

 

The latest version of this topic can be found at Input-Output Streams.

basic_iostream`, which is defined in the header file <istream>, is the class template for objects that handle both input and output character-based I/O streams.

There are two typedefs that define character-specific specializations of basic_iostream and can help make code easier to read: iostream (not to be confused with the header file <iostream>) is an I/O stream that is based on basic_iostream<char>; wiostream is an I/O stream that is based on basic_iostream<wchar_t>.

For more information, see basic_iostream Class, iostream, and wiostream.

Deriving from basic_iostream is the class template basic_fstream, which is used to stream character data to and from files.

There also are typedefs that provide character-specific specializations of basic_fstream. They are fstream, which is a file I/O stream that is based on char, and wfstream, which is a file I/O stream that is based on wchar_t. For more information, see basic_fstream Class, fstream, and wfstream. Using these typedefs requires the inclusion of the header file <fstream>.

Note

When a basic_fstream object is used to perform file I/O, although the underlying buffer contains separately designated positions for reading and writing, the current input and current output positions are tied together, and therefore, reading some data moves the output position.

The class template basic_stringstream and its common specialization, stringstream, are often used to work with I/O stream objects to insert and extract character data. For more information, see basic_stringstream Class.

See Also

stringstream
basic_stringstream Class
<sstream>
iostream Programming
C++ Standard Library