"cpp/io/basic ispanstream")
(C++23)  
[ basic_ospanstream  ](/w/cpp/io/basic_ospanstream "cpp/io/basic ospanstream")
(C++23)  
[ basic_spanstream  ](/w/cpp/io/basic_spanstream "cpp/io/basic spanstream")
(C++23)  
[ istrstream  ](/w/cpp/io/istrstream "cpp/io/istrstream") (  C++98/26*  )  
[ ostrstream  ](/w/cpp/io/ostrstream "cpp/io/ostrstream") (  C++98/26*  )  
[ strstream  ](/w/cpp/io/strstream "cpp/io/strstream") (  C++98/26*  )  
Synchronized Output  
[ basic_osyncstream  ](/w/cpp/io/basic_osyncstream "cpp/io/basic osyncstream")
(C++20)  
Types  
[ streamoff  ](/w/cpp/io/streamoff "cpp/io/streamoff")  
[ streamsize  ](/w/cpp/io/streamsize "cpp/io/streamsize")  
[ fpos  ](/w/cpp/io/fpos "cpp/io/fpos")  
Error category interface  
[ iostream_category  ](/w/cpp/io/iostream_category "cpp/io/iostream category")
(C++11)  
[ io_errc  ](/w/cpp/io/io_errc "cpp/io/io errc") (C++11)  
  
[ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/navbar_content&action=edit)

C++ includes the following input/output libraries: an [ OOP-style
](https://en.wikipedia.org/wiki/Object-oriented_programming "enwiki:Object-
oriented programming") stream-based I/O  library  ,  print-based family  of
functions  (since C++23)  , and the standard set of  C-style I/O  functions.

##  Contents

  * 1  Stream-based I/O 
    * 1.1  Abstraction 
    * 1.2  File I/O implementation 
    * 1.3  String I/O implementation 
    * 1.4  Array I/O implementations 
    * 1.5  Synchronized output 
    * 1.6  Typedefs 
    * 1.7  Predefined standard stream objects 
    * 1.8  I/O Manipulators 
    * 1.9  Types 
    * 1.10  Error category interface 
  * 2  Print functions  (since C++23) 
  * 3  C-style I/O 

  
---  
  
###  [ [ edit ](/mwiki/index.php?title=cpp/io&action=edit&section=1 "Edit
section: Stream-based I/O") ]  Stream-based I/O

The stream-based input/output library is organized around abstract
input/output devices. These abstract devices allow the same code to handle
input/output to files, memory streams, or custom adaptor devices that perform
arbitrary operations (e.g. compression) on the fly.

Most of the classes are templated, so they can be adapted to any basic
character type. Separate typedefs are provided for the most common basic
character types (  char  and  wchar_t  ). The classes are organized into the
following hierarchy:

![std-io-complete-
inheritance.svg](https://upload.cppreference.com/mwiki/images/0/06/std-io-
complete-inheritance.svg)

Inheritance diagram

#####  Abstraction  
  
---  
Defined in header ` [ <ios> ](/w/cpp/header/ios "cpp/header/ios") `  
[ ios_base  ](/w/cpp/io/ios_base "cpp/io/ios base") |  manages formatting flags and input/output exceptions   
(class)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/dsc_ios_base&action=edit)  
[ basic_ios  ](/w/cpp/io/basic_ios "cpp/io/basic ios") |  manages an arbitrary stream buffer   
(class template)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/dsc_basic_ios&action=edit)  
Defined in header ` [ <streambuf> ](/w/cpp/header/streambuf
"cpp/header/streambuf") `  
[ basic_streambuf  ](/w/cpp/io/basic_streambuf "cpp/io/basic streambuf") |  abstracts a raw device   
(class template)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/dsc_basic_streambuf&action=edit)  
Defined in header ` [ <ostream> ](/w/cpp/header/ostream "cpp/header/ostream")
`  
[ basic_ostream  ](/w/cpp/io/basic_ostream "cpp/io/basic ostream") |  wraps a given abstract device (  [ std::basic_streambuf ](/w/cpp/io/basic_streambuf "cpp/io/basic streambuf") )   
and provides high-level output interface  
(class template)  [ [edit]
](https://en.cppreference.com/mwiki/index.php?title=Template:cpp/io/dsc_basic_ostream&action=edit)  
Defined in header ` [ <istream> ](/w/cpp/header/istream "cpp/header/istream")
`  
[ basic_istream  ](/w/cpp/io/basic_istream "cpp/io/basic istream") |  wraps a given abstract device (  [