The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
 lang="en" dir="ltr">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>
    C++ I/O    [C++ Reference]
  </title>

  <meta name="generator" content="DokuWiki Release 2009-12-25c &quot;Lemming&quot;" />
<meta name="robots" content="index,follow" />
<meta name="date" content="2010-04-18T22:30:09-0700" />
<meta name="keywords" content="io,start" />
<link rel="search" type="application/opensearchdescription+xml" href="/wiki/lib/exe/opensearch.php" title="C++ Reference" />
<link rel="start" href="/wiki/" />
<link rel="contents" href="/wiki/io/start?do=index" title="Index" />
<link rel="alternate" type="application/rss+xml" title="Recent Changes" href="/wiki/feed.php" />
<link rel="alternate" type="application/rss+xml" title="Current Namespace" href="/wiki/feed.php?mode=list&amp;ns=io" />
<link rel="edit" title="Edit this page" href="/wiki/io/start?do=edit" />
<link rel="alternate" type="text/html" title="Plain HTML" href="/wiki/_export/xhtml/io/start" />
<link rel="alternate" type="text/plain" title="Wiki Markup" href="/wiki/_export/raw/io/start" />
<link rel="canonical" href="http://www.cppreference.com/wiki/io/start" />
<link rel="stylesheet" media="all" type="text/css" href="/wiki/lib/exe/css.php?s=all&amp;t=custom1&amp;tseed=1272971091" />
<link rel="stylesheet" media="screen" type="text/css" href="/wiki/lib/exe/css.php?t=custom1&amp;tseed=1272971091" />
<link rel="stylesheet" media="print" type="text/css" href="/wiki/lib/exe/css.php?s=print&amp;t=custom1&amp;tseed=1272971091" />
<script type="text/javascript" charset="utf-8" ><!--//--><![CDATA[//><!--
var NS='io';var JSINFO = {"id":"io:start","namespace":"io"};
//--><!]]></script>
<script type="text/javascript" charset="utf-8" src="/wiki/lib/exe/js.php?tseed=1272971091" ></script>

  <link rel="shortcut icon" href="/wiki/lib/tpl/custom1/images/favicon.png" />

  </head>

<body>
<div class="dokuwiki">
  
  <div class="stylehead">

    <div class="breadcrumbs">
      <span class="bchead">You are here: </span><a href="../start.html"  title="start">C++ Reference</a> &raquo; <a href="../io/start.html"  title="io:start">C++ I/O</a>    </div>
    
  </div>


  
  
  <div class="page">

    <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-2828341-1";
urchinTracker();
</script>
    <!-- wikipage start -->
    


<h1><a name="c_io" id="c_io">C++ I/O</a></h1>
<div class="level1">

<p>

The &lt;iostream&gt; library automatically defines a few standard objects:

</p>
<ul>
<li class="level1"><div class="li"> cout, an object of the ostream class, which displays data to the standard output device.</div>
</li>
<li class="level1"><div class="li"> cerr, another object of the ostream class that writes unbuffered output to the standard error device.</div>
</li>
<li class="level1"><div class="li"> clog, like cerr, but uses buffered output.</div>
</li>
<li class="level1"><div class="li"> cin, an object of the istream class that reads data from the standard input device.</div>
</li>
</ul>

<p>

The &lt;fstream&gt; library allows programmers to do file input and output
with the ifstream and ofstream classes.  C++ programmers can also do
input and output from strings by using the <a href="../io/sstream/start.html" class="wikilink1" title="io:sstream:start">stringstream</a> class.
</p>

<p>
Some of the behavior of the C++ I/O streams (precision, justification,
etc) may be modified by manipulating various <a href="../io/io_flags.html" class="wikilink1" title="io:io_flags">I/O stream
format flags</a>.
</p>
<table class="inline">
	<tr class="row0">
		<td class="col0"><a href="../io/constructors.html" class="wikilink1" title="io:constructors">I/O Constructors</a></td><td class="col1">constructors</td>
	</tr>
	<tr class="row1">
		<td class="col0"><a href="../io/bad.html" class="wikilink1" title="io:bad">bad</a></td><td class="col1">true if an error occurred</td>
	</tr>
	<tr class="row2">
		<td class="col0"><a href="../io/clear.html" class="wikilink1" title="io:clear">clear</a></td><td class="col1">clear and set status flags</td>
	</tr>
	<tr class="row3">
		<td class="col0"><a href="../io/close.html" class="wikilink1" title="io:close">close</a></td><td class="col1">close a stream</td>
	</tr>
	<tr class="row4">
		<td class="col0"><a href="../io/eof.html" class="wikilink1" title="io:eof">eof</a></td><td class="col1">true if at the end-of-file</td>
	</tr>
	<tr class="row5">
		<td class="col0"><a href="../io/exceptions.html" class="wikilink1" title="io:exceptions">exceptions</a></td><td class="col1">set the stream to throw exceptions on errors</td>
	</tr>
	<tr class="row6">
		<td class="col0"><a href="../io/fail.html" class="wikilink1" title="io:fail">fail</a></td><td class="col1">true if an error occurred</td>
	</tr>
	<tr class="row7">
		<td class="col0"><a href="../io/fill.html" class="wikilink1" title="io:fill">fill</a></td><td class="col1">manipulate the default fill character</td>
	</tr>
	<tr class="row8">
		<td class="col0"><a href="../io/flags.html" class="wikilink1" title="io:flags">flags</a></td><td class="col1">access or manipulate io_stream_format_flags</td>
	</tr>
	<tr class="row9">
		<td class="col0"><a href="../io/flush.html" class="wikilink1" title="io:flush">flush</a></td><td class="col1">empty the buffer</td>
	</tr>
	<tr class="row10">
		<td class="col0"><a href="../io/gcount.html" class="wikilink1" title="io:gcount">gcount</a></td><td class="col1">number of characters read during last input</td>
	</tr>
	<tr class="row11">
		<td class="col0"><a href="../io/get.html" class="wikilink1" title="io:get">get</a></td><td class="col1">read characters</td>
	</tr>
	<tr class="row12">
		<td class="col0"><a href="../io/getline.html" class="wikilink1" title="io:getline">getline</a></td><td class="col1">read a line of characters</td>
	</tr>
	<tr class="row13">
		<td class="col0"><a href="../io/good.html" class="wikilink1" title="io:good">good</a></td><td class="col1">true if no errors have occurred</td>
	</tr>
	<tr class="row14">
		<td class="col0"><a href="../io/ignore.html" class="wikilink1" title="io:ignore">ignore</a></td><td class="col1">read and discard characters</td>
	</tr>
	<tr class="row15">
		<td class="col0"><a href="../io/is_open.html" class="wikilink1" title="io:is_open">is_open</a></td><td class="col1">check if a file is open</td>
	</tr>
	<tr class="row16">
		<td class="col0"><a href="../io/open.html" class="wikilink1" title="io:open">open</a></td><td class="col1">open a new stream</td>
	</tr>
	<tr class="row17">
		<td class="col0"><a href="../io/peek.html" class="wikilink1" title="io:peek">peek</a></td><td class="col1">check the next input character</td>
	</tr>
	<tr class="row18">
		<td class="col0"><a href="../io/precision.html" class="wikilink1" title="io:precision">precision</a></td><td class="col1">manipulate the precision of a stream</td>
	</tr>
	<tr class="row19">
		<td class="col0"><a href="../io/put.html" class="wikilink1" title="io:put">put</a></td><td class="col1">write characters</td>
	</tr>
	<tr class="row20">
		<td class="col0"><a href="../io/putback.html" class="wikilink1" title="io:putback">putback</a></td><td class="col1">return characters to a stream</td>
	</tr>
	<tr class="row21">
		<td class="col0"><a href="../io/rdstate.html" class="wikilink1" title="io:rdstate">rdstate</a></td><td class="col1">returns the state flags of the stream</td>
	</tr>
	<tr class="row22">
		<td class="col0"><a href="../io/read.html" class="wikilink1" title="io:read">read</a></td><td class="col1">read data into a buffer</td>
	</tr>
	<tr class="row23">
		<td class="col0"><a href="../io/seekg.html" class="wikilink1" title="io:seekg">seekg</a></td><td class="col1">perform random access on an input stream</td>
	</tr>
	<tr class="row24">
		<td class="col0"><a href="../io/seekp.html" class="wikilink1" title="io:seekp">seekp</a></td><td class="col1">perform random access on output streams</td>
	</tr>
	<tr class="row25">
		<td class="col0"><a href="../io/setf.html" class="wikilink1" title="io:setf">setf</a></td><td class="col1">set format flags</td>
	</tr>
	<tr class="row26">
		<td class="col0"><a href="../io/sync_with_stdio.html" class="wikilink1" title="io:sync_with_stdio">sync_with_stdio</a></td><td class="col1">synchronize with standard I/O</td>
	</tr>
	<tr class="row27">
		<td class="col0"><a href="../io/tellg.html" class="wikilink1" title="io:tellg">tellg</a></td><td class="col1">read input stream pointers</td>
	</tr>
	<tr class="row28">
		<td class="col0"><a href="../io/tellp.html" class="wikilink1" title="io:tellp">tellp</a></td><td class="col1">read output stream pointers</td>
	</tr>
	<tr class="row29">
		<td class="col0"><a href="../io/unsetf.html" class="wikilink1" title="io:unsetf">unsetf</a></td><td class="col1">clear io_stream_format_flags</td>
	</tr>
	<tr class="row30">
		<td class="col0"><a href="../io/width.html" class="wikilink1" title="io:width">width</a></td><td class="col1">access and manipulate the minimum field width</td>
	</tr>
	<tr class="row31">
		<td class="col0"><a href="../io/write.html" class="wikilink1" title="io:write">write</a></td><td class="col1">write characters</td>
	</tr>
</table>

</div>

    <!-- wikipage stop -->
  </div>

  <div class="clearer">&nbsp;</div>

  
  <div class="stylefoot">

    <div class="meta">
      <div class="user">
              </div>
      <!--
      <div class="doc">
        io/start.txt &middot; Last modified: 04/18/2010 22:30 by dnglaze      </div>
      -->
    </div>

   
    </div></div></body>
</html>